A=set([y-x for x,y in [list(map(int,input().split())) for i in '1'*int(input())]]) x=A.pop() print((-1,x)[len(A)==0 and x>0])