a = []
while True:
temp = int(input())
if temp != 0:
a.append(temp)
else:
break
if a != []:
print(max(a))
print(0)