#include <bits/stdc++.h>
#define N 200010
#define INF 10000000000000000
#define ll long long
using namespace std;
ll n,a[N],sum=0,pos=0,ans=INF;
int main(){
	ll i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	for(i=n-1;i>0;i--)
	{
		sum-=a[i];
		pos+=a[i];
		ans=min(ans,abs(sum-pos));
	}
	cout<<ans<<endl;
	return 0;
}