#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
const double INF = 1e18;
int n;
int a[100010];
long long s[100010], f[100010];
int main() {
  scanf("%d", &n);
  scanf("%d", &a[1]);
  s[1] = a[1];
  for (int i = 2; i <= n; i++) {
    char op;
    scanf(" %c", &op);
    scanf("%d", &a[i]);
    if (op == '-') a[i] = -a[i];
    s[i] = a[i] + s[i - 1];
  }
  f[n] = a[n];
  long long mx = -s[n];
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] < 0) {
      f[i] = a[i] + f[i + 1];
      f[i] = max(f[i], a[i] + s[i] + mx);
    } else
      f[i] = a[i] + f[i + 1];
    mx = max(mx, f[i + 1] - s[i]);
  }
  cout << f[1] << endl;
  return 0;
}
