let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let z = Array.fold_left (+) 0 a in
  let ans = ref max_int in
  for i = 0 to n - 2 do
    let t = abs (z - 2 * a.(i)) in
    if t < !ans then ans := t;
  done;
  Printf.printf "%d\n" !ans