#include <bits/stdc++.h>
template <typename T>
T gcd(T a, T b) {
  return ((a % b == 0) ? b : gcd(b, a % b));
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;
namespace Problem {
using namespace std;
class Solver {
 public:
  int n;
  vector<LL> a;
  vector<int> op;
  vector<vector<LL>> dp;
  Solver(LL n) : n(n), a(n), op(n), dp(n, vector<LL>(2)){};
  void solve() {
    op[0] = 1;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (i < n - 1) {
        char c;
        cin >> c;
        op[i + 1] = (c == '+' ? 1 : -1);
      }
    }
    if (n == 1) {
      cout << a[0] << endl;
    } else if (n == 2) {
      cout << a[0] + a[1] * op[1] << endl;
    } else {
      int cumsum = 0;
      dp[0][0] = a[0];
      dp[0][1] = -LINF;
      dp[1][0] = a[0] + a[1] * op[1];
      dp[1][1] = -LINF;
      for (int i = 2; i < n; ++i) {
        if (op[i - 1] == 1) {
          dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i] * op[i];
          if (cumsum <= -2)
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - a[i] * op[i];
          else
            dp[i][1] = dp[i - 1][1] - a[i] * op[i];
        } else {
          dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i] * op[i];
          dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - a[i] * op[i];
        }
        cumsum += op[i - 1];
      }
      cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
    }
  }
};
}  // namespace Problem
int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  long long n = 0;
  std::cin >> n;
  Problem::Solver sol(n);
  sol.solve();
  return 0;
}
