#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long a[maxn];
long long dp[2][maxn];
long long cnt[2][maxn];
char op[10];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%lld", &a[1]);
  for (int i = 2; i <= n; i++) {
    scanf("%s %lld", op, &a[i]);
    if (op[0] == '-') a[i] = -a[i];
  }
  long long ans = 0;
  int beg = 1;
  while (beg <= n && a[beg] >= 0) {
    ans += a[beg];
    beg++;
  }
  dp[0][beg] = dp[1][beg] = a[beg];
  cnt[1][beg] = 1;
  for (int i = beg + 1; i <= n; i++) {
    if (a[i] < 0) {
      dp[0][i] = max(dp[1][i - 1], dp[0][i - 1]) + a[i];
      cnt[0][i] =
          dp[1][i - 1] >= dp[0][i - 1] ? cnt[1][i - 1] + 1 : cnt[0][i - 1];
      dp[1][i] = max(dp[0][i - 1] + a[i], dp[1][i - 1] - a[i]);
      cnt[1][i] = dp[1][i - 1] - a[i] > dp[0][i - 1] + a[i] ? cnt[1][i - 1]
                                                            : cnt[0][i - 1] + 1;
    } else {
      if (dp[1][i - 1] > dp[0][i - 1] && cnt[1][i - 1]) {
        dp[0][i] = dp[1][i - 1] + a[i];
        cnt[0][i] = cnt[1][i - 1] - 1;
      } else {
        dp[0][i] = dp[0][i - 1] + a[i];
        cnt[0][i] = cnt[0][i - 1];
      }
      if (dp[0][i - 1] > dp[1][i - 1] && cnt[0][i - 1]) {
        dp[1][i] = dp[0][i - 1] - a[i];
        cnt[1][i] = cnt[0][i - 1] - 1;
      } else {
        dp[1][i] = dp[1][i - 1] - a[i];
        cnt[1][i] = cnt[1][i - 1];
      }
    }
  }
  cout << ans + max(dp[0][n], dp[1][n]) << endl;
}
