#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60);
long long max(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
int N;
long long A[100005];
long long dp[100005][3];
int main() {
  for (int i = 0; i < 100005; i++)
    for (int j = 0; j < 3; j++) dp[i][j] = -INF;
  cin >> N;
  cin >> dp[0][0];
  for (int i = 0; i < N - 1; i++) {
    char ch;
    long long x;
    cin >> ch >> x;
    if (ch == '+') {
      dp[i + 1][0] = dp[i][0] + x;
      dp[i + 1][1] = max(dp[i][1] - x, dp[i][2] - x);
      dp[i + 1][2] = dp[i][2] + x;
    } else if (ch == '-') {
      dp[i + 1][0] = -INF;
      dp[i + 1][1] = max(dp[i][0] - x, dp[i][1] - x, dp[i][2] - x);
      dp[i + 1][2] = max(dp[i][1] + x, dp[i][2] + x);
    }
  }
  cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << endl;
  return 0;
}
