T = list(map(int,input().split())) for i in range(7): if T[i]==-1: print(-1) elif sum(T[:i+1]) > 6000: print(-1) else: print(6000 - sum(T[:i+1]))