思路:很明显的尺取,从两端不停向中间走,遇到相等就更新。不相等就小的移动。
//#define pei_pei_
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<set>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FI first
#define SE second
#define _for(type,i,a,b) for(type i=(a);i<(b);++i)
#define _efor(type,i,a,b) for(type i=(a);i<=(b);++i)
#define _rfor(type,i,a,b) for(type i=(a);i>(b);--i)
#define _refor(type,i,a,b) for(type i=(a);i>=(b);--i)
#define _sfor(p,st) for(auto &p:st)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
const double pi=acos(-1.0);
const double eps=1e-8;
const int mod=100003;
const int _mod=998244353;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int maxn=200010;
ull base=1331;
//-------------------------------------------------------------------
int a[200010];
//-------------------------------------------------------------------
signed main(){
//ifstream cin("D:\\in.txt");
//ofstream cout("D:\\out.txt");
IOS;
#ifdef pei_pei_
double be=clock();
#endif // err
//==================================================================
int n;
cin>>n;
_for(int,i,0,n)
cin>>a[i];
int l=-1,r=n;
int sl=0,sr=0;
int ans=0;
while(l<r){
if(sl==sr){
ans=l+1+n-r;
l++;
sl+=a[l];
}
if(sl>sr){
r--;
sr+=a[r];
}
if(sl<sr){
l++;
sl+=a[l];
}
}
cout<<ans<<'\n';
//==================================================================
#ifdef pei_pei_
double en=clock();
cout<<endl<<"time: "<<fixed<<setprecision(8)<<en-be<<" ms";
#endif // err
return 0;
}