s=list(set(-eval(input().replace(" ","-"))for i in [0]*int(input())));print(s[0]if s[0]>0 and len(s)<2else-1)