input() a=list(map(int,input().split())) while len(a)!=1: for i in range(len(a)-1): a[i]+=a[i+1] a=a[:-1] print(a[0])