#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
long long dp[100010][5];
long long a;
char c;
int n;
int main() {
  cin >> n >> a;
  memset(dp, -0x3f3f3f3f3f3f3f3f, sizeof(dp));
  dp[0][0] = a;
  for (int i = 1; i < n; i++) {
    scanf(" %c%d", &c, &a);
    if (c == '+') {
      dp[i][2] = dp[i - 1][2] + a;
      dp[i][1] = max(dp[i - 1][1] - a, dp[i - 1][2] + a);
      dp[i][0] = max(dp[i - 1][0] + a, max(dp[i - 1][1] - 1, dp[i - 1][2] + a));
    } else {
      dp[i][2] = max(dp[i - 1][1] + a, dp[i - 1][2] - a);
      dp[i][1] = max(dp[i - 1][1] + a, max(dp[i - 1][2] - a, dp[i - 1][0] - a));
    }
  }
  printf("%lld\n", max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
  return 0;
}
