N = int(input()) Books = [tuple(map(int, input().split())) for _ in range(N)] adj = [[0] * N for _ in range(N)] for i, (ai, bi) in enumerate(Books): for j, (aj, bj) in enumerate(Books): adj[i][j] = bi - ai + aj INF = 20000 dp = [[INF] * (1 << N) for _ in range(N)] for i in range(N): for j in range(N): dp[i][1 << j] = 0 for b in range(1, 1 << N): for i in range(N): if not b & (1 << i): continue for j in range(N): dp[j][b | (1 << j)] = min(dp[j][b | (1 << j)], max(dp[i][b], adj[i][j])) ans = min(dp[i][-1] for i in range(N)) print(ans)