open System

[<EntryPoint>]
let main argv =
    let n = stdin.ReadLine() |> int
    let xs = stdin.ReadLine().Split() |> Array.map int
    [|Array.min xs .. Array.max xs|]
    |> Array.map (fun p ->
        xs
        |> Array.sumBy (fun x -> pown (x - p) 2)
    )
    |> Array.min
    |> stdout.WriteLine
    0
