n = int(input()) a = list(map(int, input().split())) b = [] pre = a[0] for i in range(1, n): b.append(pre + a[i]) pre = a[i] for i in range(len(b) - 1): c = b.copy() tmp = [] pre = c[0] for j in range(1, len(c)): tmp.append(pre + c[j]) pre = c[j] b = tmp print(b[0])