#include <bits/stdc++.h>
using namespace std;
const int mx = 100005;
char c;
int n, m, a;
long long ac[mx], ans = -1e15;
int main() {
  scanf("%d%lld", &n, ac);
  for (int i = 1; i < n; i++) {
    scanf(" %c %d", &c, &a);
    if (c == '+') {
      for (int i = 0; i < m; i++) {
        ac[i] = max(ac[i] + (i & 1 ? -a : a), ac[i + 1] + (i & 1 ? a : -a));
      }
      ac[m] += (m & 1 ? -a : a);
    } else {
      ac[m + 1] = ac[m] + (m & 1 ? a : -a);
      for (int i = m++; i > 0; i--) {
        ac[i] = max(ac[i] + (i & 1 ? a : -a), ac[i - 1] + (i & 1 ? -a : a));
      }
      ac[0] -= a;
    }
  }
  for (int i = 0; i <= m; i++) ans = max(ans, ac[i]);
  printf("%lld\n", ans);
}
