#include <bits/stdc++.h>
using namespace std;
int n, a[100005], f[100005], pre[100005];
long long sum, ans = -(long long)(1e16);
int main() {
  scanf("%d%d", &n, &a[1]);
  for (int i = 2; i <= n; i++) {
    char s[5];
    scanf("%s", s);
    if (s[0] == '-') f[i] = 1;
    scanf("%d", &a[i]);
  }
  for (int i = n; i > 0; i--) pre[i] = pre[i + 1] + a[i];
  int la = 1;
  while (la <= n && !f[la]) sum += 1ll * a[la++];
  while (la <= n) {
    int la1 = la + 1;
    long long sum1 = 0;
    while (la1 <= n && !f[la1]) sum1 += 1ll * a[la1++];
    if (la1 <= n) ans = max(ans, sum - sum1 - a[la] + pre[la1]);
    sum += sum1 - a[la];
    la = la1;
  }
  ans = max(ans, sum);
  printf("%lld\n", ans);
}
