#include <bits/stdc++.h>
using namespace std;
int arr[100005];
long long suf[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cin >> arr[1];
  for (int i = 2; i <= n; i++) {
    char op;
    cin >> op >> arr[i];
    if (op == '-') arr[i] *= -1;
  }
  for (int i = n; i >= 1; i--) suf[i] = suf[i + 1] + abs(arr[i]);
  long long ans = -1e18, sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += arr[i];
    if (arr[i] < 0) ans = max(ans, sum - arr[i + 1] + suf[i + 2]);
  }
  cout << ans << endl;
  return 0;
}
