#include <bits/stdc++.h>
using namespace std;
long long int dp[100002][2];
bool flag[100002];
long long int a[100002];
char buf[3];
int main() {
  int n;
  cin >> n;
  scanf("%lld", &a[0]);
  for (int i = 1; i < n; i++) {
    scanf("%s", buf);
    scanf("%lld", &a[i]);
    if (buf[0] == '-') {
      a[i] *= -1LL;
      flag[i] = true;
    }
  }
  long long int ans = 0;
  bool ok = false;
  bool f = false;
  int mul = 1;
  for (int i = 0; i < n; i++) {
    if (ok == false) {
      ans += a[i];
    }
    if (flag[i]) {
      ok = true;
      long long int sum = 0;
      for (int j = i + 1; j < n; j++) {
        if ((flag[j]) == false) {
          sum += a[j] * mul;
        } else {
          sum += a[j] * mul;
          break;
        }
      }
      mul *= -1;
      f ^= true;
      ans += max(sum, -sum);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
