#include <bits/stdc++.h>
using namespace std;
map<int, long long int> mp1;
map<int, long long int> mp2;
void insert(int k, long long int val) {
  if (mp2[k] != 0)
    mp2[k] = max(mp2[k], val);
  else
    mp2[k] = val;
}
int main() {
  int n;
  cin >> n;
  vector<long long int> a(n);
  vector<char> op(n, '+');
  cin >> a[0];
  for (int i = 1; i <= (int)n - 1; i++) {
    cin >> op[i] >> a[i];
  }
  mp1[0] = a[0];
  for (int i = 1; i <= (int)n - 1; i++) {
    auto itr = mp1.begin();
    for (int j = 0; j < (int)mp1.size(); j++) {
      int x = (*itr).first, y = (*itr).second;
      if (x == 0 && op[i] == '-')
        insert(1, y - a[i]);
      else if (x == 0 && op[i] == '+')
        insert(0, y + a[i]);
      else if (x > 0 && op[i] == '-') {
        if (x % 2 == 0) {
          insert(x + 1, y - a[i]);
          insert(x - 1, y + a[i]);
        } else {
          insert(x + 1, y + a[i]);
        }
      } else if (x > 0 && op[i] == '+') {
        if (x % 2 == 0) {
          insert(x, y + a[i]);
        } else {
          insert(x, y - a[i]);
          insert(x - 1, y + a[i]);
        }
      }
      itr++;
    }
    mp1 = mp2;
    mp2.clear();
  }
  long long int ans = (long long)-1e14;
  auto itr = mp1.begin();
  for (int j = 0; j < (int)mp1.size(); j++) {
    ans = max(ans, (*itr).second);
    itr++;
  }
  cout << ans << endl;
}
