n = int(input()) sq = list(map(int,input().split())) m1 = 0 m2 = 0 m3 = sq[0] cnt = 1 while cnt < n: print('m1 ' + str(m1)) print('m2 ' + str(m2)) print('m3 ' + str(m3)) print('sq[cnt]' + str(sq[cnt])) m4 = max([sq[cnt]+m2, sq[cnt]+m1]) print('m4 ' + str(m4)) m1,m2,m3 = m2,m3,m4 cnt += 1 print(max([m1,m2,m3]))