#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long linf = 1LL << 62;
const int MAX = 2020000;
long long dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
long long dx[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const double pi = acos(-1);
const double eps = 1e-7;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <typename T>
inline void print(T &a) {
  for (int i = 0; i < (a.size()); i++) cout << a[i] << " ";
  cout << "\n";
}
template <typename T1, typename T2>
inline void print2(T1 a, T2 b) {
  cout << a << " " << b << "\n";
}
template <typename T1, typename T2, typename T3>
inline void print3(T1 a, T2 b, T3 c) {
  cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<char> s(n);
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    if (i < n - 1) cin >> s[i + 1];
  }
  s[0] = '+';
  vector<vector<long long> > dp(n + 1, vector<long long>(3, -linf));
  dp[0][0] = 0;
  for (int i = 0; i < (n); i++) {
    if (s[i] == '+') {
      chmax(dp[i + 1][0], dp[i][0] + a[i]);
      chmax(dp[i + 1][1], dp[i][1] - a[i]);
      chmax(dp[i + 1][0], dp[i][1] - a[i]);
      chmax(dp[i + 1][1], dp[i][2] + a[i]);
    } else {
      chmax(dp[i + 1][2], dp[i][1] + a[i]);
      chmax(dp[i + 1][1], dp[i][0] - a[i]);
      chmax(dp[i + 1][0], dp[i][0] - a[i]);
      chmax(dp[i + 1][1], dp[i][1] + a[i]);
    }
  }
  cout << max(dp[n][0], dp[n][1]) << "\n";
}
