#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int f[N][4], c[N], a[N];
char op[2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    if (i != 1) scanf("%s", op);
    if (i == 1 || op[0] == '+')
      c[i] = 1;
    else
      c[i] = -1;
    scanf("%d", &a[i]);
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 2; j++) f[i][j] = -1e9;
  f[0][0] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 2; j++) {
      int tt = j == 1 ? -1 : 1;
      if (j) {
        f[i + 1][j - 1] =
            max(f[i + 1][j - 1], f[i][j] - tt * c[i + 1] * a[i + 1]);
        if (c[i + 1] == -1)
          f[i + 1][j] = max(f[i + 1][j], f[i][j] + tt * a[i + 1]);
      }
      if (c[i + 1] == -1)
        f[i + 1][j + 1] =
            max(f[i + 1][j + 1], f[i][j] + tt * c[i + 1] * a[i + 1]);
      f[i + 1][j] = max(f[i + 1][j], f[i][j] + tt * c[i + 1] * a[i + 1]);
    }
  printf("%d\n", max(f[n][0], max(f[n][1], f[n][2])));
  return 0;
}
