using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int output = -1; bool b = true; int m = 0; for (int i = 0; i < n; i++) { string[] s = Console.ReadLine().Split(); int x = int.Parse(s[0]); int y = int.Parse(s[1]); if (n == 1) { b = false; break; } if (i == 0) { m = y - x; } else if (m != y - x) { b = false; break; } } if (b == true) { output = m; } Console.WriteLine(output); Console.ReadLine(); } }