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