let n = read_int ()
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let s, x, ans = Array.fold_left (+) 0 a_s, ref 0, ref max_int
let _ = Array.iteri (fun i a -> if i < n - 1 then x := !x + a; ans := min !ans @@ abs @@ 2 * !x - s) a_s; Printf.printf "%d\n" !ans