#include <bits/stdc++.h>
using namespace std;
int read() {
  char c = getchar();
  int t = 0, f = 1;
  while (c > '9' || c < '0') f = (c == '-') ? -1 : 1, c = getchar();
  while (c >= '0' && c <= '9') t = t * 10 + c - '0', c = getchar();
  return t * f;
}
int n, op[100005];
long long sum[100005], absum[100005];
char ch[2];
int main() {
  n = read(), sum[1] = absum[1] = read();
  for (int i = 2, x; i <= n; i++) {
    scanf("%s", ch), op[i] = (ch[0] == '-') ? -1 : 1;
    x = read(), sum[i] = sum[i - 1] + x * op[i], absum[i] = absum[i - 1] + x;
  }
  long long ans = sum[n];
  for (int i = 2, j; i <= n; i = j) {
    if (op[i] > 0) continue;
    long long tmp = sum[i - 1];
    j = i + 1;
    while (op[j] > 0 && j <= n) j++;
    tmp += (absum[n] - absum[j - 1]) - (absum[j - 1] - absum[i - 1]);
    ans = max(ans, tmp);
  }
  printf("%lld\n", ans);
}
