t = list(map(int, input().split())) s = 0 for i in t: if i == -1: s += 10 ** 18 else: s += i print(max(-1, 6000 - s))