#include <bits/stdc++.h>
using namespace std;
int n, m;
long long a[100005], b[100005], sum, ans;
int main() {
  int i, x;
  char op;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d ", &x), sum += x;
    if (i == 1)
      op = '+';
    else
      scanf("%c", &op);
    if (op == '-')
      a[++m] = x;
    else
      b[m] += x;
  }
  if (!m) ans = sum;
  for (i = 1; i <= m; i++) {
    ans = max(ans, sum - 2 * (a[i] + b[i]));
    sum -= 2 * a[i];
  }
  cout << ans;
  return 0;
}
