using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var list = new List(N); int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); int ans = input[1] - input[0]; var tmp = 0; while (N > 0) { input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); tmp = input[1] - input[0]; if (tmp <= 0) { Console.WriteLine(-1); return; } else if(tmp == ans) list.Add(ans); N--; } int count = list.Distinct().Count(); Console.WriteLine(count == 0 ? -1 : list[0]); } }