let n = stdin.ReadLine() |> int
let mutable a = stdin.ReadLine().Split(' ') |> Array.map int
let mutable ans = 1000000000

let X = Array.sum(a)
let mutable x = 0
let mini(c,b)=
    if c > b then
        b
     else
        c

for i in[0..n-1]do
x<-x+a.[i]
if(i+1<n)then ans <- mini(ans,abs(X-2*x));;
printfn "%d" ans