using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var hst = new HashSet(); var N = int.Parse(Console.ReadLine()); int[] input; var result = 0; for (int i=0; i < N; i++) { input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); result = input[1] - input[0]; if (result <= 0) { Console.WriteLine(-1); return; } hst.Add(result); } Console.WriteLine(hst.Count() == 1 ? hst.First() : -1); } }