We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).  You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down.  The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them.  At most how many candies can you collect when you choose the best way to travel?
def main():
    N = int(input())
    A = [list(map(int,input().split())) for _ in range(2)]

    right = 0
    under = 0
    ans = A[0][0] + A[1][N-1]

    for i in range(1,N):
        print(ans)
        for j in range(i,N):
            right += A[0][j]

        under += A[1][i-1]
        for h in range(i,N-1):
            under += A[1][h]

        if under < right:
            ans += A[0][i]
            right = 0
            under = 0
        else:
            ans += under
            return ans

    return ans

print(main())

def main():
    N = int(input())
    A = [list(map(int,input().split())) for _ in range(2)]

    right = 0
    under = 0
    ans = A[0][0] + A[1][N-1]
    temp = 0
    for i in range(N):
        for j in range(1,i+1):
            temp += A[0][j]

        for k in range(i,N-1):
            temp += A[1][k]

        judge = A[0][0] + A[1][N-1] + temp
        if judge > ans:
            ans = judge

        judge = 0
        temp = 0

    return ans

print(main())
