let m = pown 10 9 |> (+) 7 |> int64 let addMod x y = (x + y) % m let n = stdin.ReadLine() |> int64 let a = stdin.ReadLine().Split() |> Array.map int64 let rec loop xs = let len = Array.length xs if len > 1 then xs.[1..] |> Array.mapi (fun i y -> addMod xs.[i] y) |> loop elif len = 1 then xs.[0] else -1L loop a |> printfn "%d"