#include <bits/stdc++.h>
using namespace std;
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
long long read() {
  long long d = 0, w = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') w = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) d = (d << 1) + (d << 3) + c - 48;
  return d * w;
}
void wln(long long x) {
  write(x);
  putchar('\n');
}
void wrs(long long x) {
  write(x);
  putchar(' ');
}
long long reac() {
  char c = getchar();
  for (; c != '-' && c != '+'; c = getchar())
    ;
  return c == '+' ? 1 : -1;
}
long long n, a[100010], c[100010], f[100010][3];
signed main() {
  n = read();
  c[1] = 1;
  a[1] = read();
  for (long long i = 2; i <= n; a[i++] = read()) c[i] = reac();
  f[1][0] = a[1];
  f[1][1] = f[1][2] = -0x3f3f3f3f3f3f3f3f;
  for (long long i = 2; i <= n; i++) {
    f[i][0] = max(f[i - 1][0], f[i - 1][1]) + a[i] * c[i];
    f[i][1] =
        max(max((c[i] == -1 ? f[i - 1][0] : -0x3f3f3f3f3f3f3f3f) + a[i] * c[i],
                f[i - 1][1] + a[i] * c[i] * -1),
            f[i - 1][2] + a[i] * c[i] * -1);
    f[i][2] =
        max((c[i] == -1 ? f[i - 1][1] : -0x3f3f3f3f3f3f3f3f) + a[i] * c[i] * -1,
            f[i - 1][2] + a[i] * c[i]);
  }
  write(max(f[n][0], f[n][1]));
  return 0;
}
