#include <bits/stdc++.h>
using namespace std;
long long N;
long long A[100005];
char op[100005];
long long dp[100005][10];
int main(void) {
  cin >> N;
  N--;
  cin >> A[0];
  for (int i = 1; i <= N; i++) cin >> op[i] >> A[i];
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      dp[i][j] = -100000000000000000;
    }
  }
  dp[0][0] = A[0];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 2; j++) {
      if (dp[i][j] == -100000000000000000) continue;
      if (op[i + 1] == '+') {
        dp[i + 1][j] =
            max(dp[i + 1][j], dp[i][j] + (((j) % 2) ? -1 : 1) * A[i + 1]);
        if (j > 0)
          dp[i + 1][j - 1] =
              max(dp[i + 1][j - 1], dp[i][j] + (((j) % 2) ? -1 : 1) * A[i + 1]);
      } else {
        dp[i + 1][j] =
            max(dp[i + 1][j], dp[i][j] + (((j + 1) % 2) ? -1 : 1) * A[i + 1]);
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1],
                               dp[i][j] + (((j + 1) % 2) ? -1 : 1) * A[i + 1]);
        if (j > 0)
          dp[i + 1][j - 1] = max(
              dp[i + 1][j - 1], dp[i][j] + (((j + 1) % 2) ? -1 : 1) * A[i + 1]);
      }
    }
  }
  cout << dp[N][0] << endl;
  return 0;
}
