#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const long long INF = 1e16;
char opt[MAXN];
int n, kind = 0;
long long val[MAXN], ans = -INF, sum[MAXN];
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
void init() {
  long long t1 = val[1], t2 = 0, temp;
  for (int i = 1; i <= n - 1; i++) {
    if (opt[i] == '+') {
      t1 += val[i + 1];
      continue;
    }
    int now = i + 1;
    temp = -val[i + 1];
    while (now < n && opt[now] == '+') {
      now++;
      temp -= val[now];
    }
    ans = max(ans, t1 + t2 + temp + sum[n] - sum[now]);
    t2 -= val[i + 1];
  }
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &val[i]);
    sum[i] = sum[i - 1] + val[i];
    if (i != n) cin >> opt[i];
  }
  init();
  printf("%lld\n", ans);
  return 0;
}
