1N = int(input())
2P = list(map(int, input().split()))
3
4D = [P[0]]+[0]*(N-1)
5
6for i in range(1, N):
7 for j in range(1, i+1):
8 D[i] = max(D[i-j]+P[j-1], D[i])
9 D[i] = max(P[i], D[i])
10
11print (D[N-1]
1N = int(input())
2P = list(map(int, input().split()))
3
4D = [P[0]]+[0]*(N-1)
5
6for i in range(1, N):
7 for j in range(1, i+1):
8 D[i] = max(D[i-j]+P[j-1], D[i])
9 D[i] = max(P[i], D[i])
10
11print (D[N-1]