import java.util.*; public class Main { static int n; static int[] positions; static int[] sizes; static int[][] dp; public static void main (String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); positions = new int[n]; sizes = new int[n]; for (int i = 0; i < n; i++) { positions[i] = sc.nextInt(); sizes[i] = sc.nextInt(); } dp = new int[n][1 << n]; for (int[] arr : dp) { Arrays.fill(arr, -1); } int min = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { min = Math.min(min, dfw(i, (1 << n) - 1)); } System.out.println(min); } static int dfw(int idx, int mask) { if (dp[idx][mask] < 0) { int next = ((1 << idx) ^ mask); if (next == 0) { dp[idx][mask] = 0; return 0; } int min = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { if (((1 << i) & next) == 0) { continue; } int length = sizes[idx] - positions[idx] + positions[i]; min = Math.min(min, Math.max(length,dfw(i, next))); } dp[idx][mask] = min; } return dp[idx][mask]; } }