1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include "maklib.h"
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
	int size = Size();
	long long prev = ElementAt(1);
	long long mx=max(prev,(long long)0);
	for (int i = 2; i <= size; i++)
	{
		unsigned long long tmp = ElementAt(i);
		if (prev>0) prev += tmp;
		else prev = tmp;
		mx = max(mx, prev);
	}
	if (mx < 0)	cout << 0 << endl;
	else cout << mx << endl;
  return 0;
}