#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	ll sum{};
	ll ans = LONG_MAX;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		sum += arr[i];
	}
	ll r2{};
	for(int i=0;i<n-1;i++)
	{
		r2 += arr[i];
		ans = min(ans,abs(sum - 2*r2));
	}	
	cout<<ans;
	return 0;
}