N = int(input()) A = list(map(int,input().split())) dp = [0]*(1<