#include <bits/stdc++.h>
using namespace std;
int N;
signed long long A[101010];
signed long long S[101010];
signed long long O[101010];
signed long long ret = 0;
signed long long mi[101010], ma[101010];
int nex[101010], nex2[101010];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  cin >> A[0];
  for (i = 0; i < (N - 1); i++) {
    cin >> s >> A[i + 1];
    O[i + 1] = (s[0] == '+') ? 1 : -1;
  }
  for (i = 0; i < (N); i++) S[i + 1] = S[i] + A[i];
  nex[N] = N;
  nex[N - 1] = N;
  for (i = N - 2; i >= 0; i--) {
    if (O[i + 1] == -1)
      nex[i] = i + 1;
    else
      nex[i] = nex[i + 1];
  }
  if (N == 1) return (void)printf("%lld\n", A[0]);
  if (N == 2) return (void)printf("%lld\n", A[0] + O[1] * A[1]);
  mi[N - 1] = ma[N - 1] = A[N - 1];
  for (i = N - 2; i >= 0; i--) {
    if (O[i + 1] == 1) {
      ma[i] = A[i] + ma[i + 1];
      mi[i] = A[i] + mi[i + 1];
    } else {
      ma[i] = max(A[i] - A[i + 1] + ma[i + 2], A[i] - A[i + 1] - mi[i + 2]);
      ma[i] = max(ma[i], A[i] - mi[i + 1]);
      mi[i] = min(A[i] - A[i + 1] - ma[i + 2], A[i] - A[i + 1] + mi[i + 2]);
      mi[i] = min(mi[i], A[i] - ma[i + 1]);
      if (nex[i + 1] < N) {
        mi[i] = min(mi[i], A[i] - (S[nex[i + 1]] - S[i + 1]) - mi[nex[i + 1]]);
      }
    }
  }
  cout << ma[0] << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
