stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long

using namespace std;

int read(){

	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();

	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();

	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;

}int n,a[1000000],ans;

signed main(){

	n=read();for (int i=1;i<=n;i++)a[i]=read()+a[i-1];

	ans=1e15;for (int i=1;i<n;i++)ans=min(ans,abs(a[n]-a[i]*2));

	cout<<ans<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.1500521601286815x):
#include<stdio.h>

#include<stdlib.h>

 

 

int main()

{ 

	long long int n;

	scanf("%lld",&n);	

	long long int *a = NULL;

	a = (long long int *)malloc(sizeof(long long int)*n);

	long long int *b = NULL;

	b = (long long int *)malloc(sizeof(long long int)*n);

	



	long long int sum = 0;

	for (int i = 0; i < n; i++)

	{

		scanf("%lld", &a[i]);

		sum += a[i];

	 }

	long long int t = 0,m;

		 

	for (int i = 0; i<n;i++)

	{

		t += a[i];

		if (sum - 2 * t >= 0) 

			b[i] = sum - 2 * t;

		else b[i]=2*t-sum;

	}

	m = b[0];

	for (int i = 0; i < n-1; i++)

		if (b[i] < m)

			m = b[i];

 

	

	printf("%lld\n", m);

	free(a);

	free(b);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()

{

	cin.tie(0);

	cout.tie(0);

	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	ll *a = new ll[n];

	ll* b = new ll[n];

	int tmp = 0;

	while (n--)

		cin >> a[tmp++];

	b[0] = a[0];

	for (int i = 1; i < tmp; i++)

		b[i] =b[i-1]+ a[i];

	ll min = abs(b[tmp-1] - 2 * b[0]);

	for (int i = 1; i < tmp - 1; i++)

		min =((min > abs(b[tmp-1] - 2 * b[i])) ? (abs(b[tmp-1] - 2 * b[i])) : min);

	cout << min << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.286178440091615x):
#include<stdio.h>

#include<stdlib.h>

 

 

int main()

{ 

	long long int n;

	scanf("%lld",&n);	

	long long int *a = NULL;

	a = (long long int *)malloc(sizeof(long long int)*n);

	long long int *b = NULL;

	b = (long long int *)malloc(sizeof(long long int)*n);

	



	long long int sum = 0;

	for (int i = 0; i < n; i++)

	{

		scanf("%lld", &a[i]);

		sum += a[i];

	 }

	long long int t = 0,m;

		 

	for (int i = 0; i<n;i++)

	{

		t += a[i];

		if (sum - 2 * t >= 0) 

			b[i] = sum - 2 * t;

		else b[i]=2*t-sum;

	}

	m = b[0];

	for (int i = 0; i < n-1; i++)

		if (b[i] < m)

			m = b[i];

 

	

	printf("%lld\n", m);

	free(a);

	free(b);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef set<int> si;



const int SIZE = 2e5 + 10;



ll s[SIZE] = {0};



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);



    int n;

    ll t;

    cin >> n;

    for (int i = 1; i <= n; i++)

    {

        cin >> t;

        s[i] = s[i - 1] + t;

    }

    ll res = LONG_MAX;

    for (int i = 1; i <= n - 1; i++)

        res = min(res, abs(s[n] - 2 * s[i]));



    cout << res << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.286739380022962x):
#include<stdio.h>

#include<stdlib.h>

 

 

int main()

{ 

	long long int n;

	scanf("%lld",&n);	

	long long int *a = NULL;

	a = (long long int *)malloc(sizeof(long long int)*n);

	long long int *b = NULL;

	b = (long long int *)malloc(sizeof(long long int)*n);

	



	long long int sum = 0;

	for (int i = 0; i < n; i++)

	{

		scanf("%lld", &a[i]);

		sum += a[i];

	 }

	long long int t = 0,m;

		 

	for (int i = 0; i<n;i++)

	{

		t += a[i];

		if (sum - 2 * t >= 0) 

			b[i] = sum - 2 * t;

		else b[i]=2*t-sum;

	}

	m = b[0];

	for (int i = 0; i < n-1; i++)

		if (b[i] < m)

			m = b[i];

 

	

	printf("%lld\n", m);

	free(a);

	free(b);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

long long a[200050];

int main(){



	int n,i,j;

	long long x=0,y=0,sum=0;

	cin>>n;

	for(i=0;i<n;i++){

		cin>>a[i];

		y+=a[i];

	}

	sum = abs(y-a[0]*2);

	for(i=0;i<n-1;i++){

		x+=a[i];

		y-=a[i];

		if(abs(x-y)<sum) sum=abs(x-y);

	}

	cout<<sum;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.21628969560631x):
#include<stdio.h>

#include<stdlib.h>

 

 

int main()

{ 

	long long int n;

	scanf("%lld",&n);	

	long long int *a = NULL;

	a = (long long int *)malloc(sizeof(long long int)*n);

	long long int *b = NULL;

	b = (long long int *)malloc(sizeof(long long int)*n);

	



	long long int sum = 0;

	for (int i = 0; i < n; i++)

	{

		scanf("%lld", &a[i]);

		sum += a[i];

	 }

	long long int t = 0,m;

		 

	for (int i = 0; i<n;i++)

	{

		t += a[i];

		if (sum - 2 * t >= 0) 

			b[i] = sum - 2 * t;

		else b[i]=2*t-sum;

	}

	m = b[0];

	for (int i = 0; i < n-1; i++)

		if (b[i] < m)

			m = b[i];

 

	

	printf("%lld\n", m);

	free(a);

	free(b);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

const int MAXN = 2e5 + 100;

long long x,sum[MAXN],n,min_,i;

int main()

{

    cin>>n;

    sum[0]=0;

    for(i=1;i<=n;i++)

       {

           cin>>x;

           sum[i]=sum[i-1]+x;

       }

    min_=abs(2*sum[1]-sum[n]);

   for(i=2;i<n;i++)

   {

       min_=min_<abs(2*sum[i]-sum[n])?min_:abs(2*sum[i]-sum[n]);

   }

    cout<<min_;

}

// Faster C++ solution for the same problem (measured speedup: 5.160420078444171x):
#include<stdio.h>

#include<stdlib.h>

 

 

int main()

{ 

	long long int n;

	scanf("%lld",&n);	

	long long int *a = NULL;

	a = (long long int *)malloc(sizeof(long long int)*n);

	long long int *b = NULL;

	b = (long long int *)malloc(sizeof(long long int)*n);

	



	long long int sum = 0;

	for (int i = 0; i < n; i++)

	{

		scanf("%lld", &a[i]);

		sum += a[i];

	 }

	long long int t = 0,m;

		 

	for (int i = 0; i<n;i++)

	{

		t += a[i];

		if (sum - 2 * t >= 0) 

			b[i] = sum - 2 * t;

		else b[i]=2*t-sum;

	}

	m = b[0];

	for (int i = 0; i < n-1; i++)

		if (b[i] < m)

			m = b[i];

 

	

	printf("%lld\n", m);

	free(a);

	free(b);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

typedef long long LL;

const int MAXN = 2e5 + 5;

const int MOD = 1000000000;

const LL INF = (2e5)*(1e9) + 5;

LL a[MAXN];

LL sum[MAXN];



int main()

{

	ios::sync_with_stdio(false);

	int n;

	while (cin >> n)

	{

		LL tot = 0;

		for (int i = 1; i <= n; i++)

		{

			cin >> a[i];

			sum[i] = sum[i - 1] + a[i];

			tot += a[i];

		}

		LL Min = INF;

		for (int i = 1; i<n; i++)

		{

			if (Min>abs(2 * sum[i] - tot))

				Min = abs(2 * sum[i] - tot);

		}

		cout << Min << endl;

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.282562198767972x):
#include<stdio.h>

#include<stdlib.h>

 

 

int main()

{ 

	long long int n;

	scanf("%lld",&n);	

	long long int *a = NULL;

	a = (long long int *)malloc(sizeof(long long int)*n);

	long long int *b = NULL;

	b = (long long int *)malloc(sizeof(long long int)*n);

	



	long long int sum = 0;

	for (int i = 0; i < n; i++)

	{

		scanf("%lld", &a[i]);

		sum += a[i];

	 }

	long long int t = 0,m;

		 

	for (int i = 0; i<n;i++)

	{

		t += a[i];

		if (sum - 2 * t >= 0) 

			b[i] = sum - 2 * t;

		else b[i]=2*t-sum;

	}

	m = b[0];

	for (int i = 0; i < n-1; i++)

		if (b[i] < m)

			m = b[i];

 

	

	printf("%lld\n", m);

	free(a);

	free(b);

	return 0;

}
// Slower C++ solution:
  #include <bits/stdc++.h>

  

  long long a[200005];

  

  long long abs(long long in){

    return in > 0 ? in : -in;

  }

  

  int main(){

    int n;

    long long min = 2e9 + 5;

    long long sum = 0;

    scanf("%d", &n);

    for(int i = 0;i < n;++i) {

      scanf("%lld", &a[i]);

      sum += a[i];

    }

    if(n == 2) {

      printf("%lld\n", abs(a[0] - a[1]));

      return 0;

    }

    else {

      for(long long j = 1, x = a[0];j < n - 1;++j){

        x += a[j];

        //for(int j = 1;j <= i;++j) x += a[j];

        //printf("%d %d\n", x, sum - x);

        if(abs(sum - 2 * x) < min) min = abs(sum - 2 * x);

      }

    }

    printf("%lld\n", min);

    return 0;

  }

// Faster C++ solution for the same problem (measured speedup: 5.166274775716108x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
    #include<iostream>

    using namespace std;

    int main(){

    	int n;

    	cin>>n;

    	long long int sum=0;

    	int a[200000];

    	for(int i=0;i<n;i++){

    		cin>>a[i];

    		sum+=a[i];

    	}

    	sum-=a[n-1];

    	long long int k=a[n-1];

    	long long int min=abs(sum-k);

    	for(int i=n-2;i>0;i--){

    		sum-=a[i];

    		k+=a[i];

    		if(abs(sum-k)<min){

    			min=abs(sum-k);

    		}

    		

    	}

    	cout<<min;

    

    }

// Faster C++ solution for the same problem (measured speedup: 5.296013818722791x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

#include <cmath>

int A[200000];



int main()

{

int N;

cin >> N ;

for (long long i=0;i<N;i++)

{

	cin >> A[i];

}	

long long b=A[0];

long long c=0;

for (int i=1;i<N;i++)

{

	c = c+A[i]; 

}

long long min = abs(c-b);	

for (int i=1;i<N-1;i++){

b= b+A[i];

c= c-A[i]; 

if(abs(c-b)<min) min=abs(c-b); 

} 

cout << min << endl; 

return 0;	

}

// Faster C++ solution for the same problem (measured speedup: 5.228223747568644x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<cstring>

#include<algorithm>

#define M 200010

#define inf 2000000010

using namespace std;

int n,a[M];

long long ans,t,sum;

int main()

{

    while(scanf("%d",&n)!=EOF)

    {

        sum = 0; ans = inf; t = 0;

        for (int i = 0; i < n; i++)

        {

            scanf("%d",&a[i]);

            sum+=a[i];

        }

       for (int i = 0; i < n-1; i++)

       {

            t += a[i];

            if(ans > abs(2 * t - sum))

                ans = abs(2 * t - sum);

       }

        printf("%lld\n",ans);

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.166783332773141x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define N 200020

#define ll long long

using namespace std;

inline ll read(){

	ll x=0,f=1;char ch=getchar();

	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());

	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();

	return f?x:-x;

}

ll a[N], sum, ans = 1ll << 60;

int main(int argc, char const *argv[]) {

	int n = read();

	for (int i = 1; i <= n; i++)

		sum += a[i] = read();

	for (int i = 1; i < n; i++) {

		a[i] += a[i - 1];

		ans = min(ans, abs(a[i] * 2 - sum));

	}

	cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.1652401251518x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#define For(i,j,k)	for(int i=j;i<=k;++i)

#define Dow(i,j,k)	for(int i=k;i>=j;--i)

#define ll long long

#define inf 1e8

using namespace std;

inline ll read()

{

	ll t=0,f=1;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-')	f=-1;c=getchar();}

	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();

	return t*f;

}

ll a[200001],sum[200001],ans=1e17,n;

int main()

{

	n=read();

	For(i,1,n)	a[i]=read();

	For(i,1,n)	sum[i]=sum[i-1]+a[i];

	Dow(i,1,n-1)

		ans=min(ans, abs(sum[n]-sum[i]-sum[i]) );

	cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.2056017267558x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long

using namespace std;

int read(){

	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();

	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();

	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;

}int n,a[1000000],ans;

signed main(){

	n=read();for (int i=1;i<=n;i++)a[i]=read()+a[i-1];

	ans=1e15;for (int i=1;i<n;i++)ans=min(ans,abs(a[n]-a[i]*2));

	cout<<ans<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.165548474401898x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()

{

	cin.tie(0);

	cout.tie(0);

	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	ll *a = new ll[n];

	ll* b = new ll[n];

	int tmp = 0;

	while (n--)

		cin >> a[tmp++];

	b[0] = a[0];

	for (int i = 1; i < tmp; i++)

		b[i] =b[i-1]+ a[i];

	ll min = abs(b[tmp-1] - 2 * b[0]);

	for (int i = 1; i < tmp - 1; i++)

		min =((min > abs(b[tmp-1] - 2 * b[i])) ? (abs(b[tmp-1] - 2 * b[i])) : min);

	cout << min << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.302084353248408x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef set<int> si;



const int SIZE = 2e5 + 10;



ll s[SIZE] = {0};



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);



    int n;

    ll t;

    cin >> n;

    for (int i = 1; i <= n; i++)

    {

        cin >> t;

        s[i] = s[i - 1] + t;

    }

    ll res = LONG_MAX;

    for (int i = 1; i <= n - 1; i++)

        res = min(res, abs(s[n] - 2 * s[i]));



    cout << res << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3026469810270225x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

long long a[200050];

int main(){



	int n,i,j;

	long long x=0,y=0,sum=0;

	cin>>n;

	for(i=0;i<n;i++){

		cin>>a[i];

		y+=a[i];

	}

	sum = abs(y-a[0]*2);

	for(i=0;i<n-1;i++){

		x+=a[i];

		y-=a[i];

		if(abs(x-y)<sum) sum=abs(x-y);

	}

	cout<<sum;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.231985316145663x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

const int MAXN = 2e5 + 100;

long long x,sum[MAXN],n,min_,i;

int main()

{

    cin>>n;

    sum[0]=0;

    for(i=1;i<=n;i++)

       {

           cin>>x;

           sum[i]=sum[i-1]+x;

       }

    min_=abs(2*sum[1]-sum[n]);

   for(i=2;i<n;i++)

   {

       min_=min_<abs(2*sum[i]-sum[n])?min_:abs(2*sum[i]-sum[n]);

   }

    cout<<min_;

}

// Faster C++ solution for the same problem (measured speedup: 5.175947589395709x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

typedef long long LL;

const int MAXN = 2e5 + 5;

const int MOD = 1000000000;

const LL INF = (2e5)*(1e9) + 5;

LL a[MAXN];

LL sum[MAXN];



int main()

{

	ios::sync_with_stdio(false);

	int n;

	while (cin >> n)

	{

		LL tot = 0;

		for (int i = 1; i <= n; i++)

		{

			cin >> a[i];

			sum[i] = sum[i - 1] + a[i];

			tot += a[i];

		}

		LL Min = INF;

		for (int i = 1; i<n; i++)

		{

			if (Min>abs(2 * sum[i] - tot))

				Min = abs(2 * sum[i] - tot);

		}

		cout << Min << endl;

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.298457230789915x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include<algorithm>

using namespace std;

int a[200005];

long long int s[200005],r[200005],m[200005],sum=0;

int main()

{

	int n;

	r[0]=0;

	scanf("%d",&n);

	for(int i=1;i<=n;i++)

	    {

		scanf("%d",&a[i]);

	    sum=sum+a[i];

	    s[i]=s[i-1]+a[i];

	    }

	for(int j=1;j<n;j++)

	{

		r[j]=sum-s[j];

		m[j]=abs(s[j]-r[j]);

	}

	sort(m,m+n);

	printf("%d\n",m[1]);

}

// Faster C++ solution for the same problem (measured speedup: 5.20701194962947x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>



//记得修改scanf_s

int main()

{

	long int n,*a;

	scanf("%ld", &n);

	a = (long int *)malloc(n * sizeof(long int));

	for (int i = 0; i < n; i++)

		scanf("%ld", &a[i]);



	double sum = 0, sum1 = 0;

	for (int i = 0; i < n; i++)

		sum += a[i];



	long int min = fabs(2 * a[0] - sum);

	for (int i = 0; i < n - 1; i++)

	{

		sum1 += a[i];

		if (min > fabs(2 * sum1 - sum))

			min = fabs(2 * sum1 - sum);

	}

	printf("%ld\n", min);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <queue>

#include <numeric>

#include <climits>

#include <iterator>

#include <iomanip>

#include <stack>

#include <bitset>

#include <functional>

using namespace std;

const constexpr int INF = 1e9;

//typedef std::pair<std::string,double> P;



typedef long long ll;

typedef vector<int> VI;



#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)

#define REP(i, n) FOR(i, 0, n)



//グラフの隣接リスト

VI g[200010];

//頂点の入次数を管理

int h[100010];

ll N;



int a[200010];

ll sum[200010];

signed main(void) {

    cin >> N;

    REP(i, N) cin >> a[i];

    FOR(i, 0, N) sum[i+1] = sum[i]+a[i];

    

    ll ans=10000000000;

    for(int i=1; i<N; ++i){

        ans = min(ans, abs(sum[N]-sum[i]-sum[i]));

    }

    cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.475312246716438x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <string>

#include <queue>

using namespace std;

using ll = long long;

#define INF 1LL << 59

//西暦⇒時代の歴



ll a[201000];

ll N;

int main()

{

    cin >> N;

    ll l = 0LL;

    ll r = 0;

    for (int i = 0; i < N; ++i)

    {

        cin >> a[i];

    }

    for (int i = 0; i < N; ++i)

        r += a[i];



    ll minV = INF;



    for (int i = 0; i < N - 1; ++i)

    {

        l += a[i];

        r -= a[i];

        minV = min(minV, abs(l - r));

    }

    cout << minV << endl;

    return 0;

}