#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int n;
long long a[200000];
long long b[200000];
string c[200000];
long long solve() {
  long long res = 0, sum = 0;
  long long count = 0;
  for (int i = (1); i < (n); i++)
    if (c[i - 1] == "-") a[i] = -a[i];
  for (int i = (1); i < (n); i++) {
    b[i] = count;
    if (c[i - 1] == "-") count++;
  }
  for (int i = (0); i < (n); i++) {
    if (b[i] == 0)
      res += a[i];
    else if (b[i] == 1) {
      if (b[i - 1] == 0) {
        sum += -a[i - 1];
        res -= a[i - 1];
      }
      sum += a[i];
    } else
      res += max(a[i], -a[i]);
  }
  res -= sum;
  return res;
}
int main() {
  cin >> n >> a[0];
  for (int i = (1); i < (n); i++) cin >> c[i - 1] >> a[i];
  cout << solve() << endl;
  return 0;
}
