#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
bool flag[100010];
char s[20];
long long pre[100010];
long long sum, ans = -0x3FFFFFFF;
int main() {
  scanf("%d", &n);
  flag[1] = 0;
  scanf("%d", &a[1]);
  for (int i = 2; i <= n; i++) {
    scanf("%s", s);
    if (s[0] == '-') flag[i] = 1;
    scanf("%d", &a[i]);
  }
  for (int i = n; i >= 1; i--) pre[i] = pre[i + 1] + a[i];
  int las = 1;
  while (flag[las] == 0 && las <= n) {
    sum += a[las];
    las++;
  }
  while (las <= n) {
    int las1 = las + 1;
    long long sum1 = 0;
    while (flag[las1] == 0 && las1 <= n) {
      sum1 += a[las1];
      las1++;
    }
    if (las1 <= n) ans = max(ans, sum - sum1 - a[las] + pre[las1]);
    las = las1;
    sum -= a[las];
    sum += sum1;
  }
  ans = max(ans, sum);
  printf("%lld", ans);
}
