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