N = int(input()) H =list(map(int,input().split())) now = 0 stack = [] for i in range(N): h = H[i] if i % 2 == 0: if len(stack) == 0: now = h stack.append((0,h)) print(now) else: while True: if stack: a,b = stack.pop() if b <= h: now -= b - a continue elif a <= h <= b: now += a stack.append((0,b)) break else: now += h stack.append((a,b)) stack.append((0,h)) break else: now += h stack.append((0,h)) break print(now) else: while True: if len(stack) == 0: break else: a,b = stack.pop() if b <= h: now -= b - a continue elif a <= h < b: now -= h - a stack.append((h,b)) break else: break print(now)