from itertools import accumulate T = list(map(lambda x: int(x), input().split())) acc = list(accumulate(T)) ALL = 6000 is_finish = False for i in range(7): if T[i] == -1 or is_finish or ALL - acc[i] < 0: print(-1) is_finish = True continue print(ALL - acc[i] if ALL - acc[i] >= 0 else 0)