#include using namespace std; long largestValue(vector a) { long s=0; int max_ending_here=0; int max_so_far=0; int start =0; int end=0; for(int i=0;i< a.size();i++){ max_ending_here=max_ending_here+a[i]; if(max_ending_here<0) { start=i+1; //Every time it goes negative start from next index max_ending_here=0; } else end =i; //As long as its positive keep updating the end if(max_so_far> n; vector A(n); for(int A_i = 0; A_i < n; A_i++){ cin >> A[A_i]; } long result = largestValue(A); cout << result << endl; return 0; }