#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
char c;
int a[N];
bool b[N];
int main() {
  int n;
  scanf("%d", &n);
  bool flag = false;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i < n) {
      c = getchar();
      while (c != '-' && c != '+') c = getchar();
      if (c == '-')
        b[i + 1] = true;
      else
        b[i + 1] = false;
    }
  }
  long long ans = 0, sum = a[1];
  for (int i = 2; i <= n; i++)
    if (b[i]) {
      sum -= a[i];
      if (flag)
        ans += ((sum) < 0 ? -(sum) : (sum));
      else
        flag = true, ans += sum;
      sum = 0;
    } else
      sum += a[i];
  if (flag)
    ans += ((sum) < 0 ? -(sum) : (sum));
  else
    ans += sum;
  cout << ans << endl;
}
