#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005];
long long b[100005], sum, ans;
char op[100005];
int main() {
  int i, p;
  scanf("%d", &n);
  for (i = 1; i < n; i++) scanf("%d %c ", &a[i], &op[i]);
  scanf("%d", &a[n]);
  for (i = 1; i < n - 1; i++)
    if (op[i] == '-' && op[i + 1] == '-') break;
  p = i + 1, i += 2;
  while (i <= n) a[p] -= a[i++];
  n = p, sum = a[1];
  for (i = 1; i < n; i++)
    if (op[i] == '-')
      sum -= a[i + 1], b[++m] = sum, sum = 0;
    else
      sum += a[i + 1];
  ans += sum + b[1];
  for (i = 2; i <= m; i++) ans += abs(b[i]);
  cout << ans;
  return 0;
}
