#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    long long int a[100005];
    int op[100005];
    op[0] = 1;
    scanf("%lld", &a[0]);
    for (int i = 1; i < n; i++) {
      char c;
      while (scanf("%c", &c) && c != '+' && c != '-')
        ;
      if (c == '+')
        op[i] = 1;
      else
        op[i] = 0;
      scanf("%lld", &a[i]);
    }
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i];
    }
    long long int ans = 1e18;
    int i;
    for (i = 0; op[i] == 1; i++)
      ;
    int last = i;
    long long int ssum = 0, sssum = a[i];
    for (; i < n; i++) {
      ssum += a[i];
      if (op[i + 1] == 0 || i + 1 == n)
        ans = min(ssum + sssum - a[last], ans), ssum = 0;
      if (op[i + 1] == 0) sssum += a[i + 1], last = i + 1;
    }
    ans = min(sssum, ans);
    printf("%lld\n", sum - 2 * ans);
  }
}
