#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << ' ' << H;
  debug_out(T...);
}
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 5, M = 1e2 + 2;
long long A[N], DP[N][M];
bool P[N];
long long Sign(long long i) { return i & 1 ? -1 : 1; }
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  mt19937 Rnd(time(0));
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < M; j++) DP[i][j] = -INF;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    if (i) {
      char c;
      cin >> c;
      P[i] = (c == '+');
    }
    cin >> A[i];
  }
  DP[0][0] = A[0];
  for (long long i = 1; i < n; i++)
    for (long long j = M - 1; j >= 0; j--) {
      if (P[i])
        DP[i][j] = DP[i - 1][j] + A[i] * Sign(j);
      else if (j)
        DP[i][j] = DP[i - 1][j - 1] + A[i] * Sign(j);
      if (j + 1 < M) DP[i][j] = max(DP[i][j], DP[i][j + 1]);
    }
  cout << DP[n - 1][0] << '\n';
  return 0;
}
