stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cstdlib>

using namespace std;



int main()

{

       long long N;

       long long Sum_t[200000]={0};



       cin>>N;

       cin>>Sum_t[0];

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

       {

             cin>>Sum_t[i];

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

        }



       long long min=abs(Sum_t[N-1]-2*Sum_t[0]);

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

        {

                long long temp=abs(Sum_t[N-1]-2*Sum_t[i]);

                if(temp<min) min=temp;

         }

   

        cout<<min;

        return 0;

}

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

#define   ll  long long int

#define   sz  1000100



using namespace std;





ll num[sz];





int main()

{





    ll n,b,s=0,k,x,y,a,i,j,d;



    cin>>n;



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

    {

        cin>>num[i];

        s+=num[i];

    }



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

    {

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



    }



        x=num[1];

        y=s-x;

        d=abs(x-y);

        a=d;







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

    {

        x=num[i];

        y=s-x;



        d=abs(x-y);

        a=min(a,d);

    }





    cout<<a<<endl;





    return 0;

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



#include <stdio.h>

using namespace std; 

typedef long ll;



 int main(){



    int length;

    ll arr[200000];

    ll res[200000]={0};

    ll temp = 0;

    ll m = 2147483647;

    scanf("%d",&length);

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

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

   	}

   	res[0] = arr[0];

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

    	res[i] += res[i-1] + arr[i];

    }

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

    	temp = abs(res[length-1]-res[i-1]*2);

    	m = min(temp,m);

    }

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





 	return 0;

 }


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

using namespace std;

int main()

{

   long long  int n,a,i,sum=0,sum1=0,l,s=0,dif,mx;

    vector<int>v;

    cin>>n;

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

    {cin>>a;

    v.push_back(a);

    s+=a;



    }





      for(int i=n-1;i>=1;i--)

      {

          s-=v[i];

          sum+=v[i];

          dif=abs(s-sum);

          if(i==n-1){mx=dif;}

        else  {



            if(mx>dif)

            {

                mx=dif;

            }

          }

      }

cout<<mx<<endl;



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



long long int abs_1(long long int i){

	if(i<0) return -i;

	else return i;

}

int main()

{

	 int N,i,j;

	 long long int sum1=0,sum=0;

	scanf("%d",&N);

	long long int a[200000]={0},x,min=2e+9;

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

	{

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

		sum+=a[i];

	}

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

	{

		sum1+=a[i];

		x=abs_1(2*sum1-sum);

		if(x<=min)

		{

			min=x;

		}

	}

	printf("%lld",min);

	return 0;

}

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

using namespace std;

int main()

{

   long long  int n,a,i,sum=0,sum1=0,l,s=0,dif,mx;

    vector<int>v;

    cin>>n;

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

    {cin>>a;

    v.push_back(a);

    s+=a;



    }





      for(int i=n-1;i>=1;i--)

      {

          s-=v[i];

          sum+=v[i];

          dif=abs(s-sum);

          if(i==n-1){mx=dif;}

        else  {



            if(mx>dif)

            {

                mx=dif;

            }

          }

      }

cout<<mx<<endl;



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

using namespace std;

int main()

{

	int a[200010];

	long long int b[200010];

	int N = 2;

	cin >> N;

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

	{

		cin >> a[i];

	}

	long long int sum = 0;

	long long int m, n;

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

	{

		sum = sum + a[j];

	}

	m = sum;

	n = sum;

	long long int x[200009], y[200009];

	for (int j = 1; j <= (N - 1); j++)

	{

		y[j] = sum - a[j];

		sum = sum - a[j];

	}

	for (int k = 1; k <= (N - 1); k++)

	{

		x[k] = m - y[k];

		m = n;

	}

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

	{

		b[n] = abs(x[n] - y[n]);

	}

	long long int min = b[1];

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

	{

		if (min > b[i])

			min = b[i];

	}

	cout << min<<endl;

	return 0;

}

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

using namespace std;

int main()

{

   long long  int n,a,i,sum=0,sum1=0,l,s=0,dif,mx;

    vector<int>v;

    cin>>n;

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

    {cin>>a;

    v.push_back(a);

    s+=a;



    }





      for(int i=n-1;i>=1;i--)

      {

          s-=v[i];

          sum+=v[i];

          dif=abs(s-sum);

          if(i==n-1){mx=dif;}

        else  {



            if(mx>dif)

            {

                mx=dif;

            }

          }

      }

cout<<mx<<endl;



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

#include<cstdlib>

using namespace std;



int main()

{

       long long N;

       long long Sum_t[200000]={0};



       cin>>N;

       cin>>Sum_t[0];

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

       {

             cin>>Sum_t[i];

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

        }



       long long min=abs(Sum_t[N-1]-2*Sum_t[0]);

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

        {

                long long temp=abs(Sum_t[N-1]-2*Sum_t[i]);

                if(temp<min) min=temp;

         }

   

        cout<<min;

        return 0;

}

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

using namespace std;

int main()

{

   long long  int n,a,i,sum=0,sum1=0,l,s=0,dif,mx;

    vector<int>v;

    cin>>n;

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

    {cin>>a;

    v.push_back(a);

    s+=a;



    }





      for(int i=n-1;i>=1;i--)

      {

          s-=v[i];

          sum+=v[i];

          dif=abs(s-sum);

          if(i==n-1){mx=dif;}

        else  {



            if(mx>dif)

            {

                mx=dif;

            }

          }

      }

cout<<mx<<endl;



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



#include <stdio.h>

using namespace std; 

typedef long ll;



 int main(){



    int length;

    ll arr[200000];

    ll res[200000]={0};

    ll temp = 0;

    ll m = 2147483647;

    scanf("%d",&length);

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

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

   	}

   	res[0] = arr[0];

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

    	res[i] += res[i-1] + arr[i];

    }

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

    	temp = abs(res[length-1]-res[i-1]*2);

    	m = min(temp,m);

    }

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





 	return 0;

 }


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

using namespace std;



int main() {

	int n;

	cin >> n;

	vector<int> a(n);

	long long s = 0;

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

		cin >> a[i];

		s += a[i];

	}

	long long s1 = 0, res = LONG_MAX;

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

		s1 += a[i];

		res = min(res, abs(s1 - (s - s1)));

	}

	cout << res;

	return 0;

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



long long int abs_1(long long int i){

	if(i<0) return -i;

	else return i;

}

int main()

{

	 int N,i,j;

	 long long int sum1=0,sum=0;

	scanf("%d",&N);

	long long int a[200000]={0},x,min=2e+9;

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

	{

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

		sum+=a[i];

	}

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

	{

		sum1+=a[i];

		x=abs_1(2*sum1-sum);

		if(x<=min)

		{

			min=x;

		}

	}

	printf("%lld",min);

	return 0;

}

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

using namespace std;



int main() {

	int n;

	cin >> n;

	vector<int> a(n);

	long long s = 0;

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

		cin >> a[i];

		s += a[i];

	}

	long long s1 = 0, res = LONG_MAX;

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

		s1 += a[i];

		res = min(res, abs(s1 - (s - s1)));

	}

	cout << res;

	return 0;

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

using namespace std;

int main()

{

	int a[200010];

	long long int b[200010];

	int N = 2;

	cin >> N;

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

	{

		cin >> a[i];

	}

	long long int sum = 0;

	long long int m, n;

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

	{

		sum = sum + a[j];

	}

	m = sum;

	n = sum;

	long long int x[200009], y[200009];

	for (int j = 1; j <= (N - 1); j++)

	{

		y[j] = sum - a[j];

		sum = sum - a[j];

	}

	for (int k = 1; k <= (N - 1); k++)

	{

		x[k] = m - y[k];

		m = n;

	}

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

	{

		b[n] = abs(x[n] - y[n]);

	}

	long long int min = b[1];

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

	{

		if (min > b[i])

			min = b[i];

	}

	cout << min<<endl;

	return 0;

}

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

using namespace std;



int main() {

	int n;

	cin >> n;

	vector<int> a(n);

	long long s = 0;

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

		cin >> a[i];

		s += a[i];

	}

	long long s1 = 0, res = LONG_MAX;

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

		s1 += a[i];

		res = min(res, abs(s1 - (s - s1)));

	}

	cout << res;

	return 0;

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

#include<cstdlib>

using namespace std;



int main()

{

       long long N;

       long long Sum_t[200000]={0};



       cin>>N;

       cin>>Sum_t[0];

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

       {

             cin>>Sum_t[i];

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

        }



       long long min=abs(Sum_t[N-1]-2*Sum_t[0]);

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

        {

                long long temp=abs(Sum_t[N-1]-2*Sum_t[i]);

                if(temp<min) min=temp;

         }

   

        cout<<min;

        return 0;

}

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

using namespace std;



int main() {

	int n;

	cin >> n;

	vector<int> a(n);

	long long s = 0;

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

		cin >> a[i];

		s += a[i];

	}

	long long s1 = 0, res = LONG_MAX;

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

		s1 += a[i];

		res = min(res, abs(s1 - (s - s1)));

	}

	cout << res;

	return 0;

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



#include <stdio.h>

using namespace std; 

typedef long ll;



 int main(){



    int length;

    ll arr[200000];

    ll res[200000]={0};

    ll temp = 0;

    ll m = 2147483647;

    scanf("%d",&length);

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

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

   	}

   	res[0] = arr[0];

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

    	res[i] += res[i-1] + arr[i];

    }

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

    	temp = abs(res[length-1]-res[i-1]*2);

    	m = min(temp,m);

    }

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





 	return 0;

 }


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

using namespace std;

#define int long long

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;

#define pb push_back

#define ld long double

#define f first

#define s second

#define in insert

#define sz(x) (int)x.size()

#define all(x) (x).begin(), (x).end()

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e18 + 5;

const int mod = 1e9 + 7;

const int  N = 2e5 + 314;

const long double pi = 3.1415926535897932384626433832795;

void solve(){

	int n;

	cin>>n;

	vi v(n), pre(n);

	int mn = INF, s=0;

	for(int i = 0; i < n; i++)cin>>v[i];

	pre[0]=v[0];

	for(int i = 1; i < n; i++)pre[i]=v[i]+pre[i-1];

	for(int i = n-1; i >= 1; i--){

		s+=v[i];

		mn=min(mn, abs(pre[i-1]-s));

	}

	cout<<mn;

}

signed main(){

	speed;

	int t=1;

	//cin>>t;

	while(t--)solve();

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



long long int abs_1(long long int i){

	if(i<0) return -i;

	else return i;

}

int main()

{

	 int N,i,j;

	 long long int sum1=0,sum=0;

	scanf("%d",&N);

	long long int a[200000]={0},x,min=2e+9;

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

	{

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

		sum+=a[i];

	}

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

	{

		sum1+=a[i];

		x=abs_1(2*sum1-sum);

		if(x<=min)

		{

			min=x;

		}

	}

	printf("%lld",min);

	return 0;

}

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

using namespace std;

#define int long long

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;

#define pb push_back

#define ld long double

#define f first

#define s second

#define in insert

#define sz(x) (int)x.size()

#define all(x) (x).begin(), (x).end()

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e18 + 5;

const int mod = 1e9 + 7;

const int  N = 2e5 + 314;

const long double pi = 3.1415926535897932384626433832795;

void solve(){

	int n;

	cin>>n;

	vi v(n), pre(n);

	int mn = INF, s=0;

	for(int i = 0; i < n; i++)cin>>v[i];

	pre[0]=v[0];

	for(int i = 1; i < n; i++)pre[i]=v[i]+pre[i-1];

	for(int i = n-1; i >= 1; i--){

		s+=v[i];

		mn=min(mn, abs(pre[i-1]-s));

	}

	cout<<mn;

}

signed main(){

	speed;

	int t=1;

	//cin>>t;

	while(t--)solve();

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

using namespace std;

int main()

{

	int a[200010];

	long long int b[200010];

	int N = 2;

	cin >> N;

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

	{

		cin >> a[i];

	}

	long long int sum = 0;

	long long int m, n;

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

	{

		sum = sum + a[j];

	}

	m = sum;

	n = sum;

	long long int x[200009], y[200009];

	for (int j = 1; j <= (N - 1); j++)

	{

		y[j] = sum - a[j];

		sum = sum - a[j];

	}

	for (int k = 1; k <= (N - 1); k++)

	{

		x[k] = m - y[k];

		m = n;

	}

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

	{

		b[n] = abs(x[n] - y[n]);

	}

	long long int min = b[1];

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

	{

		if (min > b[i])

			min = b[i];

	}

	cout << min<<endl;

	return 0;

}

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

using namespace std;

#define int long long

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;

#define pb push_back

#define ld long double

#define f first

#define s second

#define in insert

#define sz(x) (int)x.size()

#define all(x) (x).begin(), (x).end()

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e18 + 5;

const int mod = 1e9 + 7;

const int  N = 2e5 + 314;

const long double pi = 3.1415926535897932384626433832795;

void solve(){

	int n;

	cin>>n;

	vi v(n), pre(n);

	int mn = INF, s=0;

	for(int i = 0; i < n; i++)cin>>v[i];

	pre[0]=v[0];

	for(int i = 1; i < n; i++)pre[i]=v[i]+pre[i-1];

	for(int i = n-1; i >= 1; i--){

		s+=v[i];

		mn=min(mn, abs(pre[i-1]-s));

	}

	cout<<mn;

}

signed main(){

	speed;

	int t=1;

	//cin>>t;

	while(t--)solve();

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

#include<cstdlib>

using namespace std;



int main()

{

       long long N;

       long long Sum_t[200000]={0};



       cin>>N;

       cin>>Sum_t[0];

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

       {

             cin>>Sum_t[i];

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

        }



       long long min=abs(Sum_t[N-1]-2*Sum_t[0]);

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

        {

                long long temp=abs(Sum_t[N-1]-2*Sum_t[i]);

                if(temp<min) min=temp;

         }

   

        cout<<min;

        return 0;

}

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

using namespace std;

#define int long long

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;

#define pb push_back

#define ld long double

#define f first

#define s second

#define in insert

#define sz(x) (int)x.size()

#define all(x) (x).begin(), (x).end()

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e18 + 5;

const int mod = 1e9 + 7;

const int  N = 2e5 + 314;

const long double pi = 3.1415926535897932384626433832795;

void solve(){

	int n;

	cin>>n;

	vi v(n), pre(n);

	int mn = INF, s=0;

	for(int i = 0; i < n; i++)cin>>v[i];

	pre[0]=v[0];

	for(int i = 1; i < n; i++)pre[i]=v[i]+pre[i-1];

	for(int i = n-1; i >= 1; i--){

		s+=v[i];

		mn=min(mn, abs(pre[i-1]-s));

	}

	cout<<mn;

}

signed main(){

	speed;

	int t=1;

	//cin>>t;

	while(t--)solve();

}
// 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.15077628258551x):
#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>

    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.2801261167804086x):
#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>

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.212539411493878x):
#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>

#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.151283314003975x):
#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>

#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.149744735906566x):
#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<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.189985255293233x):
#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;

}