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
low_sum = 0
high_sum = 0
for score in w:
    low_sum += score
    low = min(low, low_sum)
    low_sum = min(low_sum, 0)
    high_sum += score
    high = max(high, high_sum)
    high_sum = max(high_sum, 0)
print(high)
print(-low)
