#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define dd(x) cout<<#x<<" is "<<x<<endl;
#define dd2(x,y) cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl;
#define dl(x) cout<<#x<<" is "<<endl; for(int i=1; i<9; i++) cout<<x[i]<<' '; cout<<endl;
#define fi first
#define se second
typedef pair<int,int> pii;
const int N = 5e5+5;
int a[N];
int b[N*2];
int p[N*2];
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=n; i++) b[i] = a[i];
	for(int i=n+1; i<=2*n; i++) b[i] = a[i-n];
	
	//dl(b)
	
	for(int i=1; i<=2*n; i++) p[i] = p[i-1]+b[i];
	
	int ans = LLONG_MAX;
	for(int i=n+1; i<=n+(n+1)/2; i++){
		int j = i-(n+1)/2;
		//dd2(p[i],p[j])
		ans = min(ans,p[i]-p[j]);
	}
	
	cout<<ans;
	
	return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |