N = int(input()) L = [] for _ in range(N): x, y = map(int, input().split()) L += [y - x] L = sorted(set(L)) print([-1, *L][L[0] == L[-1] > 0])