#include <bits/stdc++.h>
using namespace std;
const int maxn = 100003;
int n, a[maxn], o[maxn];
long long f[maxn][6];
char s[3];
int main() {
  scanf("%d", &n);
  scanf("%d", &a[1]);
  for (int i = 2; i <= n; ++i) {
    scanf("%s%d", s, &a[i]);
    if (s[0] == '-') o[i] = 1;
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j < 5; ++j) f[i][j] = -1e18;
  f[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    if (!o[i]) {
      f[i][0] = max(f[i - 1][0], f[i - 1][1]) + a[i];
      f[i][1] = max(f[i - 1][1], f[i - 1][2]) - a[i];
      f[i][2] = max(f[i - 1][2], f[i - 1][3]) + a[i];
      f[i][3] = max(f[i - 1][3], f[i - 1][4]) - a[i];
      f[i][4] = f[i - 1][4] + a[i];
      continue;
    }
    f[i][0] = max(f[i - 1][0], f[i - 1][1]) - a[i];
    f[i][1] = max(f[i - 1][1], f[i - 1][2]) + a[i];
    f[i][2] = max(f[i - 1][2], f[i - 1][3]) - a[i];
    f[i][3] = max(f[i - 1][3], f[i - 1][4]) + a[i];
    f[i][4] = f[i - 1][4] - a[i];
    f[i][1] = max(f[i][1], f[i - 1][0] - a[i]);
    f[i][2] = max(f[i][2], f[i - 1][1] + a[i]);
    f[i][3] = max(f[i][3], f[i - 1][2] - a[i]);
    f[i][4] = max(f[i][4], f[i - 1][3] + a[i]);
  }
  printf("%lld\n", max(f[n][0], f[n][1]));
  return 0;
}
