【C++】已通过

using namespace std;
#define MAXINT 1000000000

int main() {
	int N; 
	while (cin >> N) {
		long long int max = -MAXINT;
		long long int f_before, f_i;
		int a; cin >> a;
		f_before = a;
		for (int i = 2; i <= N; i++) {
			 cin >> a;
			if (f_before >= 0) {
				f_i = f_before + a;
			}
			else {
				f_i = a;
			}

			//cout << "f_" << i << "=" << f_i << endl;
			max = (max >= f_i) ? max : f_i;
			f_before = f_i;
		}
		cout << max << endl;

	}
	return 0;
}