#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
long long a[maxn], per[maxn];
char c[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n;
  cin >> n >> a[0];
  per[0] = a[0];
  long long abssum = a[0];
  long long ans = a[0];
  vector<int> sub;
  for (int j = 1; j < n; ++j) {
    cin >> c[j] >> a[j];
    per[j] = per[j - 1] + a[j];
    abssum += a[j];
    if (c[j] == '+')
      ans += a[j];
    else {
      ans -= a[j];
      sub.push_back(j);
    }
  }
  for (int j = 0; j < sub.size() - 1; ++j) {
    int p1 = sub[j];
    int p2 = sub[j + 1];
    long long tis = abssum - (per[p2 - 1] - per[p1 - 1]) * 2;
    ans = max(ans, tis);
    abssum -= a[p1];
  }
  cout << ans << endl;
  return 0;
}
