#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  x = 0;
  long long f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(long long x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const long long maxn = 1e6 + 10;
const long long inf = 1e9;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
long long f[maxn][3], a[maxn], n, t[maxn];
char s[maxn];
void update(long long &x, long long y) {
  if (y > x) x = y;
}
signed main() {
  read(n);
  for (long long i = 1; i <= n; i++) {
    read(a[i]);
    if (i == n) break;
    scanf("%s", s + 1);
    if (s[1] == '-')
      t[i + 1] = -1;
    else
      t[i + 1] = 1;
  }
  t[1] = 1;
  memset(f, -63, sizeof f);
  f[0][0] = 0;
  for (long long i = 1; i <= n; i++) {
    a[i] *= t[i];
    for (long long j = 0; j <= 2; j++)
      update(f[i][j], f[i - 1][j] + (j == 1 ? -1 : 1) * a[i]);
    if (t[i] < 0) {
      for (long long j = 0; j <= 1; j++)
        update(f[i][j + 1], f[i - 1][j] + (j == 1 ? -1 : 1) * a[i]);
    }
    for (long long j = 0; j <= 1; j++)
      update(f[i][j], f[i - 1][j + 1] + (j == 1 ? -1 : 1) * a[i]);
  }
  write(max(max(f[n][0], f[n][1]), f[n][2]));
  return 0;
}
