    #include <stdio.h>
    #include <math.h>
    #define min(x,y) (x<y?x:y)
    int main()
    {
        typedef long long ll;
        ll x,sum[200009],n,ans,minn;
        scanf("%lld",&n);
        sum[0]=0;
        ll i=1;
        for(i=1;i<=n;i++)
        {
            scanf("%lld",&x);
            sum[i]=sum[i-1]+x;
        }
        ans=sum[n];
        minn=fabs(2*sum[1]-sum[n]);
        for(i=2;i<=n-1;i++)
        {
            minn=min(minn,fabs(2*sum[i]-sum[n]));
        }
        printf("%lld\n",minn);
        return 0;
    }