#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
long long dp[100001][2];
int a[100000];
char op[100000];
bool mis[100000];
int main(void) {
  int i, n;
  scanf("%d", &n);
  for (i = 0; i <= (int)(n - 1) - 1; i++) scanf("%d %c", &a[i], &op[i]);
  scanf("%d", &a[n - 1]);
  for (i = 0; i <= (int)(n - 1) - 1; i++) mis[i] = op[i] == '-';
  for (i = 0; i <= (int)(n - 1) - 1; i++) mis[i + 1] |= mis[i];
  for (i = 0; i <= (int)(n)-1; i++) {
    dp[i][0] = INF;
    dp[i][1] = -INF;
  }
  for (i = n - 1; i >= 1; i--) {
    if (op[i - 1] == '+') {
      if (mis[i - 1]) {
        dp[i][0] = min(a[i] + dp[i + 1][0], -a[i] + dp[i + 1][1]);
        dp[i][1] = max(a[i] + dp[i + 1][1], -a[i] - dp[i + 1][0]);
      } else {
        dp[i][0] = a[i] + dp[i + 1][0];
        dp[i][1] = a[i] + dp[i + 1][1];
      }
    } else {
      dp[i][0] = min(-a[i] + dp[i + 1][0], -a[i] - dp[i + 1][1]);
      dp[i][1] = max(-a[i] + dp[i + 1][1], -a[i] - dp[i + 1][0]);
    }
  }
  printf("%lld\n", dp[1][1] + a[0]);
  return 0;
}
