#include <bits/stdc++.h>
using namespace std;
const long long infty = 1000000000000000;
int N;
long long A[100010];
bool op[100010];
long long dp[100010][2];
int minusnum[100010];
int main() {
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> A[i];
    if (i < N - 1) {
      char c;
      cin >> c;
      op[i] = (c == '+');
      if (op[i]) {
        minusnum[i] = 0;
      } else {
        minusnum[i] = 1;
      }
    }
  }
  for (auto i = 0; i < N; i++) {
    minusnum[i + 1] += minusnum[i];
  }
  dp[0][0] = A[0];
  dp[0][1] = -infty;
  for (auto i = 1; i < N; i++) {
    if (op[i - 1]) {
      dp[i][1] = dp[i - 1][1] - A[i];
      dp[i][0] = max(dp[i - 1][0] + A[i], dp[i - 1][1] - A[i]);
      if (minusnum[i - 1] >= 2) {
        dp[i][1] = max(dp[i][1], dp[i - 1][1] + A[i]);
      }
    } else {
      dp[i][1] = max(dp[i - 1][1] + A[i], dp[i - 1][0] - A[i]);
      dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][0] - A[i]);
    }
  }
  cout << max(dp[N - 1][0], dp[N - 1][1]) << endl;
}
