#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
int n, ans, cnt, rec;
bool read() {
  char ch;
  while ((ch = getchar()) != '+' && ch != '-')
    ;
  return ch == '-';
}
int main() {
  scanf("%d", &n);
  for (int i = 1, a, p = 0; i <= n; ++i) {
    if (i > 1) p = read();
    scanf("%d", &a);
    if (p) {
      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("%d", ans);
  return 0;
}
