#include <bits/stdc++.h>
using namespace std;
inline void proc_status() {
  ifstream t("/proc/self/status");
  cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>())
       << endl;
}
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline T read() {
  register T sum(0), fg(1);
  register char ch(getchar());
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fg = -1;
  for (; isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
  return sum * fg;
}
const int MAXN = (int)1e5;
int n;
int A[MAXN + 5];
char type[MAXN + 5];
inline char safe_getchar() {
  register char ch(getchar());
  while (!isgraph(ch)) ch = getchar();
  return ch;
}
inline void input() {
  n = read<int>();
  type[1] = '+';
  for (int i = 1; i <= n; ++i) {
    if (i > 1) type[i] = safe_getchar();
    A[i] = read<int>();
  }
}
inline void solve() {
  long long suf = 0;
  for (int i = 1; i <= n; ++i) suf += A[i];
  long long ans = LLONG_MIN, pre = 0;
  for (int i = 1, j; i <= n; i = j) {
    long long res = A[i];
    suf -= A[i];
    for (j = i + 1; type[j] == '+'; ++j) res += A[j], suf -= A[j];
    if (i > 1) {
      chkmax(ans, pre - res + suf);
      pre += res - A[i] - A[i];
    } else
      pre += res;
  }
  chkmax(ans, pre);
  printf("%lld\n", ans);
}
int main() {
  input();
  solve();
  return 0;
}
