n = int(input())
w = [int(x) for x in input().split()]
for i in range(len(w)):
    if i % 2 != 0:
        w[i] = -w[i]
low = 0
high = 0
for i in range(n):
    sum = 0
    for v in w[i:]:
        sum += v
        low = min(low, sum)
        high = max(high, sum)
print(high)
print(-low)
