d = list(map(int, input().split(","))) n = len(d) startA = 0 endA = n startB = 0 endB = 0 w = 0 while __________: t = 0 for i in range(__________): if startA != endA: if startB != endB: if d[startA] < d[startB]: t = t + d[startA] startA += 1 else: t = t + d[startB] startB += 1 else: t = t + d[startA] startA += 1 else: t = t + d[startB] startB += 1 w += t __________ endB += 1 print(w)