N=int(raw_input()) A=map(int,raw_input().split()) dpL=[[-1 for j in range(N)] for k in range(N)] dpR=[[-1 for j in range(N)] for k in range(N)] def recL(l,r): global dpL if dpL[l][r]!=-1: return dpL[l][r] if l>r: return 0 if l==r: dpL[l][r]=1 return 1 ans=recL(l,r-1) if A[l]