input() L=list(map(int,input().split())) O,B,A=0,0,0 for V in L: A=B+V B=O O=max(A,B) print(O)