#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1ll << 60;
static const long long dx[] = {
    1,
    -1,
    0,
    0,
};
static const long long dy[] = {0, 0, 1, -1};
static const long long mod = 1000000007;
long long N;
long long A[100005];
char op[100005];
long long dp[100005][5];
long long solve() {
  for (long long i = 0; i < 100005; ++i)
    for (long long j = 0; j < 5; ++j) dp[i][j] = -INF;
  dp[0][0] = A[0];
  for (long long i = 0; i < N; ++i) {
    for (long long j = 0; j <= min(i, 3ll); ++j) {
      long long f;
      if (j % 2 == 0)
        f = 1;
      else
        f = -1;
      long long t1 = f * A[i + 1];
      if (op[i + 1] == '+') {
        dp[i + 1][j] = max(dp[i][j] + t1, dp[i + 1][j]);
        if (j != 0) dp[i + 1][j - 1] = max(dp[i][j] + t1, dp[i + 1][j - 1]);
      } else {
        dp[i + 1][j] = max(dp[i][j] - t1, dp[i + 1][j]);
        dp[i + 1][j + 1] = max(dp[i][j] - t1, dp[i + 1][j + 1]);
        if (j != 0) dp[i + 1][j - 1] = max(dp[i][j] - t1, dp[i + 1][j - 1]);
      }
    }
  }
  long long ans = -INF;
  if (ans >= INF) cout << 1 / 0 << endl;
  for (long long i = 0; i < N; ++i) ans = max(dp[N][i], ans);
  return ans;
}
signed main() {
  cin >> N;
  op[0] = '+';
  for (long long i = 0; i < N; ++i) {
    cin >> A[i];
    if (i != N - 1) cin >> op[i + 1];
  }
  cout << solve() << endl;
}
