#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const int N=1e5+10;
ll a[N];
int main()
{
	ll n,m,i,j,k,s,t,sum,l,r;
	while(~scanf("%lld",&n))
	{
		sum=0;
		for(i=1;i<=n;i++)
		scanf("%lld",&a[i]),sum+=a[i];
		l=0;
		m=1E15;
		for(i=1;i<n;i++)
		 {
		 	l+=a[i];
		 	r=sum-l;
		 	r=l-r
		 	m=min(m,llabs(r));
		 }
		 printf("%lld\n",m);
	}
	return 0;
}