a = [0] + list(map(int, input().split())) ok = True for i in range(1, 8): if a[i] == -1: ok = False if not ok: print(-1) continue s = 0 for j in range(i+1): s += a[j] if s <= 6000: print(6000-s) else: print(-1)