open Scanf ;; open Printf ;; let input_int () = scanf " %d" (fun x -> x) ;; let input_ints n = Array.init n (fun _ -> input_int ()) ;; let () = let n = input_int () in let b = input_ints n in let rec loop i s ans = if i = n then ans else begin let s' = s + b.(i) in let ans' = ans + abs (i - s) in loop (i + 1) s' ans' end in printf "%d\n" (loop 0 0 0) ;;