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