#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T>
ostream &operator<<(ostream &os, pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1000000001;
const long long INF = 1e18;
const long long MOD = 1000000007;
const double pi = 3.14159265358979323846;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  string s;
  cin >> a[0];
  for (int i = 1; i <= (n - 1); i++) {
    char c;
    cin >> c;
    s.push_back(c);
    cin >> a[i];
  }
  vector<vector<long long> > dp(n, vector<long long>(10, -INF));
  dp[0][0] = a[0];
  for (int i = 1; i <= (n - 1); i++) {
    char op = s[i - 1];
    for (int j = 0; j < (10); j++) {
      int bai;
      if (j % 2 == 0) {
        bai = 1;
      } else {
        bai = -1;
      }
      if (op == '+') {
        chmax(dp[i][j], dp[i - 1][j] + bai * a[i]);
        if (j != 0) {
          chmax(dp[i][j - 1], dp[i - 1][j] - bai * a[i]);
        }
      } else {
        chmax(dp[i][j], dp[i - 1][j] - bai * a[i]);
        if (j != 0) {
          chmax(dp[i][j - 1], dp[i - 1][j] + bai * a[i]);
        }
        if (j != 9) {
          chmax(dp[i][j + 1], dp[i - 1][j] - bai * a[i]);
        }
      }
    }
  }
  long long ans = -INF;
  for (int j = 0; j < (10); j++) {
    chmax(ans, dp[n - 1][j]);
  }
  cout << ans << endl;
}
