c92b2afeea49260266d559a04512e4b04a878c48d42358d1bee54866129434cb
// https://szkopul.edu.pl/problemset/problem/jzCvm_VOCX4120OGdoLq7RuQ/site/?key=statement
#include <bits/stdc++.h>
// #define GARY_DBG
#define GARY_LIB
constexpr int sizik = 10 * 1000 * 1001, NEW_VAL = 4 * INT16_MIN;
#define ar std::array
typedef std::vector<std::vector<int>> _kra;
std::set<std::pair<int, std::pair<int, int>>> idxs;
void solve() {
int ans = 0;
int mm_idx = 1;
std::string s;
while (std::getline(std::cin, s)) {
std::stringstream ss(s);
int x;
auto ptr = idxs.begin();
std::vector<int> to_del;
while (ss >> x) {
if (ptr == idxs.end()) {
auto [it, inserted] = idxs.insert({mm_idx++, {NEW_VAL, NEW_VAL}});
ptr = it;
}
if (x == -99) {
to_del.push_back((*ptr).first);
} else {
if ((*ptr).second.first == NEW_VAL) {
auto old = *ptr;
idxs.erase(ptr);
auto [it, inserted] = idxs.insert({old.first, {std::min(0, x), x}});
ptr = it;
ans = std::max(ans, x);
} else {
auto old = *ptr;
idxs.erase(ptr);
auto [it, inserted] = idxs.insert({old.first, {std::min(old.second.first, old.second.second + x), old.second.second + x}});
ptr = it;
ans = std::max(ans, (*ptr).second.second - old.second.first);
}
}
ptr++;
}
for (const auto& a : to_del) {
auto it = idxs.lower_bound({a, {INT32_MIN, INT32_MIN}});
if (it != idxs.end() && it->first == a) {
idxs.erase(it);
}
}
}
std::cout << ans << '\n';
}
int32_t main() {
#ifndef GARY_DBG
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
#endif
int t = 1;
// std::cin >> t;
for (; t > 0; t--) {
solve();
}
return 0;
}