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