#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
int n;
int a[MAXN];
char op[MAXN - 1];
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    scanf("%d", &a[i]);
    if (i != n - 1) scanf(" %c", &op[i]);
  }
  long long sum = 0;
  for (int i = (0); i < (n); ++i) sum += a[i];
  long long ret = a[0];
  for (int i = (0); i < (n - 1); ++i)
    if (op[i] == '+')
      ret += a[i + 1];
    else
      ret -= a[i + 1];
  long long sumneg = 0;
  int at = 0;
  while (at < n - 1 && op[at] == '+') ++at;
  while (at < n - 1) {
    int to = at + 1;
    long long sumpos = 0;
    while (to < n - 1 && op[to] == '+') sumpos += a[to + 1], ++to;
    if (to >= n - 1) break;
    long long cur = sum - 2 * (sumneg + a[at + 1] + sumpos);
    if (cur > ret) ret = cur;
    at = to;
  }
  printf("%lld\n", ret);
}
int main() {
  run();
  return 0;
}
