program A322C
    implicit none
    integer(8)::N,i,ans
    integer(8),allocatable,dimension(:)::A,Asum
    read*,N
    allocate(A(N))
    allocate(Asum(N+1))
    read*,A
    Asum=0
    do i=2,N+1
        Asum(i)=Asum(i-1)+A(i-1)
    end do
    
    do i=2,N
        if(i==2)then
            ans=abs(Asum(N+1)-2*Asum(i))
        else
            ans=min(ans,abs(Asum(N+1)-2*Asum(i)))
        end if
    end do

    print'(i0)',ans
end program A322C