#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 100010;
const int INF = 2147483600;
int N;
int opr[MAXN + 1];
int a[MAXN + 1], f[MAXN + 1][201];
inline int fan(int x, int c) {
  if (c & 1) return -x;
  return x;
}
int main() {
  N = read();
  for (int i = 1; i <= N; i++) {
    a[i] = read();
    char c;
    if (i < N) {
      c = getchar();
      getchar();
      opr[i + 1] = (c == '+' ? 1 : -1);
    }
  }
  memset(f, -127, sizeof(f));
  opr[1] = 1;
  f[0][0] = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= min(N, 200); j++) {
      if (j > 0 && opr[i] == -1)
        f[i][j] = f[i - 1][j - 1] + fan(opr[i], j - 1) * a[i];
      if (j < 200 && j < N)
        f[i][j] = max(f[i][j], f[i - 1][j + 1] + fan(opr[i], j + 1) * a[i]);
      f[i][j] = max(f[i][j], f[i - 1][j] + fan(opr[i], j) * a[i]);
    }
  }
  for (int i = 0; i <= 200; i++) f[N][0] = max(f[N][0], f[N][i]);
  printf("%d\n", f[N][0]);
  return 0;
}
