n=int(input()) v=list(map(int,input().split())) dp=[0]*n dp[0]=v[0] dp[1]=max(v[0],v[1]) if 1