#include <bits/stdc++.h>
using namespace std;
long long n, ans, cnt, rec;
long long read() {
  long long res;
  char ch;
  while (!isdigit(ch = getchar()))
    ;
  res = ch - '0';
  while (isdigit(ch = getchar())) res = res * 10 - '0' + ch;
  return res;
}
long long reado() {
  char ch;
  while ((ch = getchar()) != '+' && ch != '-')
    ;
  return ch == '-';
}
int main() {
  n = read();
  for (long long i = 1, a, o = 0; i <= n; ++i) {
    if (i > 1) o = reado();
    a = read();
    if (o) {
      switch (cnt) {
        case 0:
          ans += rec - a;
          break;
        case 1:
          ans += abs(rec - a);
          break;
        default:
          ans += rec + a;
          break;
      }
      rec = 0;
      ++cnt;
    } else
      rec += a;
  }
  ans += rec;
  printf("%lld", ans);
  return 0;
}
