#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') f = (c == '-') ? -1 : 1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
inline void fre() {
  freopen(
      "problem"
      ".in",
      "r", stdin);
  freopen(
      "problem"
      ".out",
      "w", stdout);
}
int n;
int num[100010], opt[100010];
long long sum;
int sta[100010], top = 0;
int main() {
  fre();
  n = read();
  for (int i = 1; i < n; i++) {
    num[i] = read(), sum += num[i];
    char s[5];
    scanf("%s", s);
    if (s[0] == '-')
      opt[i] = -1;
    else
      opt[i] = 1;
  }
  num[n] = read(), sum += num[n];
  long long ans = -0x7fffffff, hhh = 0;
  for (int i = 1; i < n; i++)
    if (opt[i] == -1) {
      long long tmp = sum;
      long long sum2 = num[i + 1];
      for (int j = i + 1; j < n; j++) {
        if (opt[j] == 1)
          sum2 += num[j + 1];
        else
          break;
      }
      tmp -= 2 * (sum2 + hhh);
      ans = max(ans, tmp);
      hhh += num[i + 1];
    }
  ans = max(ans, sum - 2 * hhh);
  cout << ans << endl;
}
