using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "Input4"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("2"); WillReturn.Add("3 5"); WillReturn.Add("7 9"); //2 } else if (InputPattern == "Input2") { WillReturn.Add("2"); WillReturn.Add("3 5"); WillReturn.Add("7 10"); //-1 } else if (InputPattern == "Input3") { WillReturn.Add("1"); WillReturn.Add("8 2"); //-1 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); var SikakuSet = new HashSet(); foreach (string EachStr in InputList.Skip(1)) { int[] wkArr = EachStr.Split(' ').Select(X => int.Parse(X)).ToArray(); SikakuSet.Add(wkArr[1] - wkArr[0]); } if (SikakuSet.Count >= 2) { //ユニーク解でなければNG Console.WriteLine(-1); return; } if (SikakuSet.First() <= 0) { //正整数の解でなければNG Console.WriteLine(-1); return; } Console.WriteLine(SikakuSet.First()); } }