#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long INF = 1e18;
struct lpl {
  long long data1, data2;
  int num1, num2;
} dp[maxn];
int n, f[maxn];
long long ini[maxn];
inline void putit() {
  scanf("%d", &n);
  char opt[30];
  scanf("%lld", &ini[1]);
  f[1] = 1;
  for (int i = 2; i <= n; ++i) {
    scanf("%s", opt + 1);
    f[i] = (opt[1] == '+') ? 1 : -1;
    scanf("%lld", &ini[i]);
  }
}
inline void check() {
  for (int i = 1; i <= n; ++i) {
    printf("i = %d\n", i);
    printf("num1 = %d data1 = %lld num2 = %d data2 = %lld\n", dp[i].num1,
           dp[i].data1, dp[i].num2, dp[i].data2);
  }
}
inline void workk() {
  dp[1].data1 = ini[1];
  dp[1].data2 = -INF;
  dp[1].num1 = 0;
  dp[1].num2 = 0;
  for (int i = 2; i <= n; ++i) {
    if (f[i] == 1) {
      dp[i].num1 = dp[i - 1].num1;
      dp[i].data1 = dp[i - 1].data1 + ini[i];
      if (dp[i - 1].num2 && dp[i - 1].data2 > dp[i - 1].data1) {
        dp[i].data1 = dp[i - 1].data2 + ini[i];
        dp[i].num1 = dp[i - 1].num2 - 1;
      }
      dp[i].num2 = dp[i - 1].num2;
      dp[i].data2 = dp[i - 1].data2 - ini[i];
    } else {
      dp[i].num2 = dp[i - 1].num1 + 1;
      dp[i].data2 = dp[i - 1].data1 - ini[i];
      if (dp[i].data2 < dp[i - 1].data2 + ini[i]) {
        dp[i].data2 = dp[i - 1].data2 + ini[i];
        dp[i].num2 = dp[i - 1].num2;
      }
      if (dp[i - 1].num1 && dp[i].data2 < dp[i - 1].data1 + ini[i]) {
        dp[i].num2 = dp[i - 1].num2 - 1;
        dp[i].data2 = dp[i - 1].data1 + ini[i];
      }
      dp[i].num1 = dp[i - 1].num1;
      dp[i].data1 = dp[i - 1].data1 - ini[i];
      if (dp[i - 1].num2 && dp[i - 1].data2 > dp[i - 1].data1) {
        dp[i].num1 = dp[i - 1].num2 - 1;
        dp[i].data1 = dp[i - 1].data2 - ini[i];
      }
      if (dp[i - 1].data2 + ini[i] > dp[i].data1) {
        dp[i].data1 = dp[i - 1].data2 + ini[i];
        dp[i].num1 = dp[i - 1].num2 + 1;
      }
    }
  }
  cout << max(dp[n].data1, dp[n].data2);
}
int main() {
  putit();
  workk();
  return 0;
}
