#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E16;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
void Max(long long &pos, long long val) { pos = max(pos, val); }
void Min(long long &pos, long long val) { pos = min(pos, val); }
long double EPS = 1E-9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long c[n];
  string s;
  string debri;
  for (long long i = 0; i <= n - 1; i++) {
    cin >> c[i];
    if (i != n - 1) {
      cin >> debri;
      s += debri;
    }
  }
  for (long long i = 0; i <= n - 2; i++) {
    if (s[i] == '-') break;
    if (i == n - 2) {
      long long ans = 0;
      for (long long i = 0; i <= n - 1; i++) ans += c[i];
      cout << ans << endl;
      return 0;
    }
  }
  long long spos = 0;
  long long anspre = c[0];
  for (long long i = 0; i <= n - 2; i++) {
    if (s[i] == '+') {
      anspre += c[i + 1];
    } else {
      spos = i + 1;
      break;
    }
  }
  vector<long long> a, b;
  while (spos <= n - 1) {
    a.push_back(c[spos]);
    spos++;
    long long sum = 0;
    while (spos <= n - 1 && s[spos - 1] == '+') {
      sum += c[spos];
      spos++;
    }
    b.push_back(sum);
  }
  long long vs = a.size();
  long long xs[vs], ys[vs];
  xs[0] = 0;
  for (long long i = 1; i <= vs - 1; i++) {
    xs[i] = xs[i - 1] + b[i - 1] - a[i - 1];
  }
  ys[vs - 1] = 0;
  for (long long i = vs - 2; i >= 0; i--) {
    ys[i] = ys[i + 1] + a[i + 1] + b[i + 1];
  }
  long long ans = -inf;
  for (long long i = 0; i <= vs - 1; i++) {
    Max(ans, xs[i] + ys[i] - a[i] - b[i]);
  }
  cout << ans + anspre << endl;
  return 0;
}
