#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
long long n, a[101010], dp[101010], sum[101010], x, pre,
    mn = -10000000000000000, t;
bool pm[10101];
char ch;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> x;
  dp[0] = x;
  n--;
  for (int i = 0; i <= n - 1; i++) {
    cin >> ch >> x;
    pm[i] = ch != '+';
    sum[i + 1] = x;
    a[i] = x;
  }
  for (int i = 0; i <= n - 1; i++) {
    sum[i + 1] += sum[i];
  }
  pre = -1;
  for (int i = 0; i <= n - 1; i++) {
    if (pm[i] && pre != -1) {
      chmax(mn, dp[pre] - (sum[i] - sum[pre]) - sum[i]);
    }
    if (!pm[i]) {
      dp[i + 1] = max(dp[i], mn + sum[i]) + a[i];
    } else {
      dp[i + 1] = max(dp[i] - a[i], mn + sum[i] + a[i]);
      pre = i;
    }
  }
  cout << dp[n] << '\n';
  return 0;
}
