#include <bits/stdc++.h>
using namespace std;
int n, a[666666], f[4 + 1];
char o[666666];
int main() {
  memset(f, -127 / 3, sizeof f);
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) scanf("%d%s", a + i, o + i + 1);
  scanf("%d", a + n);
  f[0] = 0;
  for (int i = n; i >= 2; --i) {
    for (int j = 1; j <= 4; ++j) f[j] = max(f[j], f[j - 1]);
    if (o[i] == '-') {
      for (int j = 1; j <= 4; ++j) f[j - 1] = max(f[j - 1], f[j]);
      for (int j = 0; j <= 4; ++j) f[j] -= (j & 1) ? (-a[i]) : a[i];
    } else
      for (int j = 0; j <= 4; ++j) f[j] += (j & 1) ? (-a[i]) : a[i];
  }
  printf("%d\n", f[0] + a[1]);
}
