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