# correct M = 10 ** 6 + 10 n = int(input()) W = [0] * (2 * M + 1) for _ in range(n): a, b = map(int, input().split()) W[M + a + 1] += 1 W[M + b + 1] -= 1 W[M + a - b + 1] -= 1 # accumulate for i in range(2 * M): W[i + 1] += W[i] S = [0] * (M + 1) S[0] = W[M] for i in range(1, M + 1): S[i] = W[M - i] + W[M + i] del W # zeta transform is_prime = [True] * (M + 1) for p in range(2, M + 1): if not is_prime[p]: continue q = M // p while q >= p: is_prime[p * q] = False # sieve S[q] += S[p * q] q -= 1 while q >= 1: S[q] += S[p * q] q -= 1 max_f, argmax = -1, 0 for m in range(1, M + 1): f_m = -n * (M // m) - S[0] - S[m] if f_m > max_f: max_f, argmax = f_m, m print(argmax)