#include <bits/stdc++.h> #define MAX 1000000 using namespace std; int main() { int n, dp[MAX]; while (cin >> n) { for (int i = 1; i <= n; i++) cin >> dp[i]; dp[0] = 0; for (int i = 2; i <= n; i++) { if (dp[i - 1] > 0) dp[i] += dp[i - 1]; } cout << dp[max_element(dp + 1, dp + n + 1) - dp]<<endl; } }