let cMajor = [| 0; 2; 4; 5; 7; 9; 11 |] let getScale key = cMajor |> Array.map ((+) key >> fun n -> n % 12) let scales = [ 0 .. 11 ] |> List.map getScale let _ = stdin.ReadLine() let ts = stdin.ReadLine().Split() |> Array.map int let fn1 scale = ts |> Array.forall (fun t -> Array.contains t scale) scales |> List.filter fn1 |> fun arr -> if arr.Length = 1 then arr.[0].[0] else -1 |> printfn "%d"