*x,=map(int,input().split()) for i in range(7): if x[i] == -1: print(-1) else: print(max(-1, 6000-sum(x[:i+1])))