#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = (1uLL << 63) - 1;
const long long mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 200005;
using namespace std;
int n;
int num[maxn];
int pos[maxn];
long long suff[maxn];
char op[5];
int main() {
  scanf("%d%d", &n, &num[0]);
  for (int i = 1; i < n; i++) {
    scanf("%s%d", op, &num[i]);
    if (op[0] == '-') num[i] *= -1;
  }
  for (int i = n - 1; i >= 0; i--) {
    suff[i] = suff[i + 1] + abs(num[i]);
  }
  long long ans = -INF;
  long long res = 0;
  num[n] = -1;
  for (int i = 0; i < n; i++) {
    if (num[i] < 0) {
      int j = i + 1;
      long long ff = num[i];
      while (j <= n && num[j] >= 0) ff -= num[j++];
      res += ff;
      ans = max(res + suff[j], ans);
      i = j - 1;
    } else
      res += num[i];
  }
  ans = max(res, ans);
  cout << ans << endl;
}
