n = int(input())
nums = list(map(int, input().split()))
before = nums[0]
res = nums[0]
for i in range(1, n):
before = max(nums[i], nums[i] + before)
res = max(res, before)
print(res)
n = int(input())
nums = list(map(int, input().split()))
before = nums[0]
res = nums[0]
for i in range(1, n):
before = max(nums[i], nums[i] + before)
res = max(res, before)
print(res)