#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int x;
  cin >> x;
  long long sum = x, sum1 = 0;
  long long pref = -1;
  bool done = 0;
  for (int i = 1; i < n; ++i) {
    char ch;
    cin >> ch >> x;
    if (ch == '-') {
      if (pref == -1)
        pref = sum;
      else if (!done) {
        done = 1;
        sum1 = sum - pref;
      }
    }
    sum += x;
  }
  cout << sum - 2 * sum1;
  return 0;
}
