open System [] let main argv = let rec readLines n=function | lst when n=0 -> lst | lst -> let line = Console.ReadLine().Split(' ') (Seq.head line |> int, Seq.last line |> int) :: lst |> readLines (n-1) let rec solve n lst= match lst, n with | (x,y)::tail, None -> solve (Some (y-x)) tail | (x,y)::tail, Some n -> if n=y-x then solve (Some n) tail else -1 | [], Some n when n > 0 -> n | _, _ -> -1 let N = Console.ReadLine () |> int [] |> (readLines N) |> solve None |> printfn "%d" 0