#include<iostream>usingnamespace std;int a[1000000];intmain(){int n; cin >> n;for(int i =0; i < n; i++){
cin >> a[i];}int sum =0, temp =0;for(int i =0; i < n; i++){
temp += a[i];if(temp > sum)
sum = temp;if(temp <0)
temp =0;}
cout << sum << endl;}
#include<iostream>#include<vector>usingnamespace std;intmain(){int n; cin >> n; vector<int>v(n);for(int i =0; i < n; i++){
cin >> v[i];}int sum=0, start=0, left=0,right=0, ans =-1, flag =1;for(int i =0; i < n; i++){
sum += v[i];if(sum <0){
sum =0;
start = i +1;}elseif(sum > ans){
ans = sum;
left = start;
right = i;}}if(ans<0){printf("0 %d %d", v[0], v[n -1]);}else{printf("%d %d %d", ans, v[left], v[right]);}}