#include <bits/stdc++.h>

using namespace std;
long long a[100005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	freopen("MUAVE.INP","r",stdin);
	freopen("MUAVE.OUT","w",stdout);
    int n;
	cin >> n;
	long long s=0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		s+=a[i];
	}
	long long d1=s-a[1], ans=s;
	for (int i = 2; i < n; i++)
        {
            d1=d1-a[i];
            ans=min(ans, abs(d1-(s-d1-a[i])));
        }
	cout << ans;
	return 0;
}
