let square x = x * x
let calc party = Array.sumBy (fun x -> square (x - party))
let fc coords =
    let min = Array.min coords
    let max = Array.max coords
    [ for x in [min..max] do calc x coords ] |> List.min

let input = [| [| 1; 4|]; [| 14; 14; 2; 13; 56; 2; 37; |] |]
for i in input do fc i |> printfn "%d"
// expected 5; 2354

[<EntryPoint>]
let main argv =
    stdin.ReadLine() |> ignore
    stdin.ReadLine() |> Array.map int |> fc |> printfn "%d"
    0