collect = [int(n) for n in input().split(' ')]
collectLen = len(collect)
sons = []
for length in range(1,collectLen + 1):
idxs = [count for count in range(0,length)]
idxsLen = len(idxs)
iendIdx = idxsLen - 1
currentAdd = iendIdx
while idxs[0] < collectLen - length + 1:
son = []
for i in range(0,idxsLen):
son.append(collect[idxs[i]])
sons.append(son)
idxs[currentAdd] += 1
while not (idxs[currentAdd] < collectLen - (iendIdx - currentAdd)):
if currentAdd == 0:
break
currentAdd -= 1
idxs[currentAdd] += 1
for i in range(currentAdd + 1,idxsLen):
idxs[i] = idxs[i - 1] + 1
currentAdd = iendIdx
total = 0
for son in sons:
total += sum(son)
print(total)