import java.util.Scanner;
public class Main {
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
int count = 0;
int min_mark = 2147483647;
int left = 0;
int right = 0;
int [] shuru = new int[n];
for(int i = 0;i<n;i++){
shuru[i] = sc.nextInt();
sum +=shuru[i];
}
double half = sum/2.0;
while(right<2*n-1&&left<n){
if(count<half){
count+=shuru[right%n];
right++;
}else{
if(count<min_mark){
min_mark = count;
count = count-shuru[left];
left++;
}else{
count = count-shuru[left];
left++;
}
}
}
if(sum == 0) System.out.println(0);
else if(left == 0) System.out.println(sum);
else System.out.println(sum-min_mark);
}
}
其中值得注意的是,这是一个圆,可能right比left小。