#include <bits/stdc++.h>
using namespace std;
struct node {
  bool is_add;
  int num;
} a[100000 + 80];
int n;
long long dp[100000 + 80][2];
long long DP(int s, bool f) {
  if ((f && dp[s][f] > -1000000000000000000LL / 2) ||
      ((!f) && dp[s][f] < 1000000000000000000LL / 2))
    return dp[s][f];
  if (s == n) return dp[s][0] = dp[s][1] = (a[s].is_add ? 1 : (-1)) * a[s].num;
  int i;
  long long S = a[s].num;
  for (i = s + 1; i <= n; i++) {
    dp[s][0] = min(dp[s][0], (f ? 1 : (-1)) * S + DP(i, 0));
    dp[s][1] = max(dp[s][1], (f ? 1 : (-1)) * S + DP(i, 1));
    if (f == 0) {
      dp[s][0] = min(dp[s][0], -S - DP(i, 1));
      dp[s][1] = max(dp[s][1], -S - DP(i, 0));
    }
    S += (a[i].is_add ? 1 : (-1)) * a[i].num;
  }
  return dp[s][f];
}
int main() {
  int i;
  char c;
  scanf("%d%d", &n, &a[1].num);
  a[1].is_add = 1;
  for (i = 1; i < n; i++) {
    while ((c = getchar()) != EOF && c ^ '+' && c ^ '-')
      ;
    a[i + 1].is_add = (c == '+');
    scanf("%d", &a[i + 1].num);
  }
  for (i = 1; i <= n; i++)
    dp[i][0] = 1000000000000000000LL, dp[i][1] = -1000000000000000000LL;
  cout << DP(1, 1);
  return 0;
}
