#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, M = 5e3 + 5, INF = 1e9, mod = 998244353;
const long long linf = 1e18;
const double eps = 1e-8, pi = acos(-1);
inline int gmin(int &a, int b) {
  if (a > b) a = b;
}
inline long long gmin(long long &a, long long b) {
  if (a > b) a = b;
}
inline int gmax(int &a, int b) {
  if (a < b) a = b;
}
inline long long gmax(long long &a, long long b) {
  if (a < b) a = b;
}
inline void read(long long &x) {
  long long f = 1, t = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    t = t * 10 + ch - '0';
    ch = getchar();
  }
  x = t * f;
}
inline long long read(long long &x, long long &y) {
  read(x);
  read(y);
}
inline void read(int &x) {
  int f = 1, t = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    t = t * 10 + ch - '0';
    ch = getchar();
  }
  x = t * f;
}
inline int read(int &x, int &y) {
  read(x);
  read(y);
}
inline void read(int &a, int &b, int &c) {
  read(a);
  read(b);
  read(c);
}
inline void read(long long &a, long long &b, long long &c) {
  read(a);
  read(b);
  read(c);
}
inline int read() {
  int x;
  read(x);
  return x;
}
inline long long qpow(long long a, long long b, long long p) {
  long long ret = 1;
  for (; b; b >>= 1, a = a * a % p)
    if (b & 1) ret = ret * a % p;
  return ret;
}
inline long long qpow(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
inline long long qmul(long long a, long long b, long long p) {
  long long ret = 0;
  for (; b; b >>= 1, a = (a << 1) % p)
    if (b & 1) {
      ret = ret + a;
      if (ret >= p)
        ret -= p;
      else if (ret < 0)
        ret += p;
    };
  return ret;
}
inline long long qmul(long long a, long long b) {
  long long ret = 0;
  for (; b; b >>= 1, a = (a << 1) % mod)
    if (b & 1) {
      ret = ret + a;
      if (ret >= mod)
        ret -= mod;
      else if (ret < 0)
        ret += mod;
    };
  return ret;
}
inline void judge() {
  freopen("data.in", "r", stdin);
  freopen("data.out", "w", stdout);
}
int n, sm;
vector<pair<long long, long long> > o;
int main() {
  read(n);
  for (int i = (1); i <= (n); i++) {
    char opt[5];
    if (i != 1)
      scanf("%s", opt);
    else
      opt[0] = '+';
    int x = read();
    sm += x;
    if (opt[0] == '-')
      o.push_back(pair<long long, long long>(x, 0));
    else if (o.size())
      o.back().second += x;
  }
  long long ans;
  if (o.size() == 0)
    ans = sm;
  else
    ans = -linf;
  for (int i = (0); i < (o.size()); i++) {
    gmax(ans, sm - 2 * (o[i].first + o[i].second));
    sm -= o[i].first * 2;
  }
  cout << ans << endl;
}
