T=list(map(int,input().split())) sm=0 for i in range(7): if T[i]==-1: print(-1) continue sm+=T[i] print(6000-sm if sm<=6000 else -1)