program OE1H
    implicit none
    integer(8)::N,i
    integer(8)::result
    integer(8)::A_sum=0
    integer(8)::snuke=0
    integer(8),allocatable,dimension(:)::A

    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    do i=1,N
        A_sum=A_sum+A(i)
    end do

    do i=1,N-1
        snuke=snuke+A(i)
        A_sum=A_sum-A(i)
        if(i==1)then
            result=abs(snuke-A_sum)
        else if(abs(snuke-A_sum)<result)then
            result=abs(snuke-A_sum)
        end if
    end do
    print'(i0)',result
end program OE1H