#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
const long long INF = 1e18;
int n, a[N], op[N];
long long dp[N][3];
int main() {
  int i, x;
  char ch[5];
  scanf("%d", &n);
  for (i = 1; i < n; i = i + 1) {
    scanf("%d%s", a + i, ch);
    op[i + 1] = (ch[0] == '-');
  }
  scanf("%d", a + n);
  dp[1][0] = a[1];
  dp[1][1] = -INF;
  dp[1][2] = -INF;
  for (i = 2; i <= n; i = i + 1) {
    if (op[i]) {
      dp[i][0] = max(max(dp[i - 1][0] - a[i], dp[i - 1][1] + a[i]),
                     dp[i - 1][2] - a[i]);
      dp[i][1] = max(max(dp[i - 1][0] - a[i], dp[i - 1][1] + a[i]),
                     dp[i - 1][2] + a[i]);
      dp[i][2] = max(dp[i - 1][1] + a[i], dp[i - 1][2] - a[i]);
    } else {
      dp[i][0] = max(max(dp[i - 1][0] + a[i], dp[i - 1][1] + a[i]),
                     dp[i - 1][2] + a[i]);
      dp[i][1] = dp[i - 1][1] - a[i];
      dp[i][2] = dp[i - 1][2] + a[i];
    }
  }
  cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);
  return 0;
}
