#include <iostream>
#include <deque>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
  int input;
  deque<int> datas;
  deque<int> sums;

  cin >> input;
  datas.push_back(input);
  while (cin >> input, input != 0) {
    datas.push_back(input);
    sums.push_back(accumulate(datas.begin(), datas.end(), 0));
    datas.pop_front();
  }

  cout << *max_element(sums.begin(), sums.end()) << endl;

  return 0;
}