N = int(input()) H = list(map(int, input().split())) stack = [] for i in range(N): if i%2 == 0: color = 0 else: color = 1 while stack and stack[-1][0] <= H[i]: stack.pop() if len(stack) == 0: if color == 0: print(H[i]) else: print(0) if color == 0: stack.append((H[i], color, H[i])) else: stack.append((H[i], color, 0)) elif stack[-1][1] == color: print(stack[-1][2]) else: if color == 0: print(stack[-1][2]+H[i]) stack.append((H[i], color, stack[-1][2]+H[i])) else: print(stack[-1][2]-H[i]) stack.append((H[i], color, stack[-1][2]-H[i]))