n = int(input()) a = list(map(int, input().strip().split())) ans = [] for i in a: if i > 0: ans.append(i) elif i <= 0: while i <= 0 and ans: i += ans[-1] ans.pop() ans.append(i) print(" ".join(map(str, ans)))