#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
template <typename T>
bool cmax(T &a, T b) {
  return (a < b) ? a = b, 1 : 0;
}
template <typename T>
bool cmin(T &a, T b) {
  return (a > b) ? a = b, 1 : 0;
}
template <typename T>
T read() {
  T ans = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') f = -1, ch = getchar();
  while (isdigit(ch))
    ans = (ans << 3) + (ans << 1) + (ch - '0'), ch = getchar();
  return ans * f;
}
template <typename T>
void write(T x, char y) {
  if (x == 0) {
    putchar('0'), putchar(y);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  static char wr[20];
  int top = 0;
  for (; x; x /= 10) wr[++top] = x % 10 + '0';
  while (top) putchar(wr[top--]);
  putchar(y);
}
void file() {}
int n;
long long dp[N][3];
const long long inf = 1e18;
void work() {
  n = read<int>();
  for (register int i = (int)(1); i <= (int)(n); ++i)
    for (register int j = (int)(0); j <= (int)(2); ++j) dp[i][j] = -inf;
  char s[5];
  int x;
  x = read<int>();
  dp[1][0] = x;
  int ty;
  for (register int i = (int)(2); i <= (int)(n); ++i) {
    scanf("%s", s);
    x = read<int>();
    ty = (s[0] == '+' ? 1 : -1);
    cmax(dp[i][0], dp[i - 1][0] + x * ty);
    cmax(dp[i][0], dp[i - 1][1] + x * ty);
    cmax(dp[i][0], dp[i - 1][2] + x * ty);
    cmax(dp[i][1], dp[i - 1][1] + x * ty * (-1));
    cmax(dp[i][1], dp[i - 1][2] + x * ty * (-1));
    if (s[0] == '-') {
      cmax(dp[i][1], dp[i - 1][0] - x);
      cmax(dp[i][1], dp[i - 1][1] - x);
      cmax(dp[i][1], dp[i - 1][2] - x);
    }
    cmax(dp[i][2], dp[i - 1][2] + x * ty);
    if (s[0] == '-') cmax(dp[i][2], dp[i - 1][1] + x);
  }
  write(max(max(dp[n][0], dp[n][1]), dp[n][2]), '\n');
}
int main() {
  work();
  return 0;
}
