n=int(input()) v=map(int,input().split()) v_i,v_s=0,0 for i in v: v_i,v_s=max(v_i,v_s),v_i+i print(max(v_i,v_s))