#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B>
bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main() {
  int n;
  cin >> n;
  vector<vector<int> > in(n, vector<int>(2));
  for (int i = 0; i < n; i++) {
    if (i) {
      char c;
      cin >> c;
      in[i][1] = c == '-';
    }
    cin >> in[i][0];
  }
  vector<vector<int> > dp(n + 1, vector<int>(3, -inf));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      if (dp[i][j] != -inf) {
        int s = in[i][0];
        if (in[i][1]) s *= -1;
        if (j == 1) s *= -1;
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + s);
        if (j < 2 && in[i][1])
          dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j] + s);
        if (j < 1 && in[i][1])
          dp[i + 1][j + 2] = max(dp[i + 1][j], dp[i][j] + s);
        if (j) dp[i + 1][j - 1] = max(dp[i + 1][j], dp[i][j] + s);
        if (j > 1) dp[i + 1][j - 2] = max(dp[i + 1][j], dp[i][j] + s);
      }
  cout << dp[n][0] << endl;
}
