import java.util.HashSet; import java.util.Scanner; public class Main { static int N; static int[] X, Y; static private void solve() { HashSet hs = new HashSet(); for (int i = 0; i < N; i++) { hs.add(new Integer(Y[i] - X[i])); } if (hs.size() > 1) { System.out.println("-1"); return; } for (Integer i : hs) { if(i.intValue() <= 0) { System.out.println("-1"); return; } System.out.println(i); } } static public void main(String[] args) { Scanner sca = new Scanner(System.in); N = sca.nextInt(); X = new int[N]; Y = new int[N]; for (int i = 0; i < N; i++) { X[i] = sca.nextInt(); Y[i] = sca.nextInt(); } solve(); } }