n = int(input())
number = list(map(int, input().split()))
sum = [number[0]]
for i in range(len(number) - 1):
sum.append(max(sum[i] + number[i + 1], number[i + 1]))
print(max(sum))
n = int(input())
number = list(map(int, input().split()))
sum = [number[0]]
for i in range(len(number) - 1):
sum.append(max(sum[i] + number[i + 1], number[i + 1]))
print(max(sum))