import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; for(int i = 0 ; i < n ; i++) { x[i] =sc.nextInt(); y[i] = sc.nextInt(); } long[] a = new long[n]; for(int i = 0 ; i < n ; i++) { a[i] = y[i] - x[i]; } for(int i = 0 ; i < n ; i++) { for(int j = i + 1 ; j < n ; j++) { if(a[i] == a[j] && a[i] > 0) { System.out.println(a[i]); return; } else { } } } System.out.println(-1); } }