let n = stdin.ReadLine() |> float
let l = stdin.ReadLine().Split() |> Array.map int
let s = l |> Array.sumBy float |> fun x -> x / n |> round |> int
l |> Array.sumBy (fun x -> (x - s) * (x - s)) |> printfn "%d"