Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop i acc =
        let calc i = Array.fold_left (fun acc v -> acc + (v - i) * (v - i)) 0 a in
        if i > 100 then acc else loop (i + 1) (min acc (calc i))
    in
    loop (-100) max_int |> Printf.printf "%d\n"
)