#include <bits/stdc++.h>
using namespace std;
const int Size = 1 << 16;
char buffer[Size], *head, *tail;
inline char Getchar() {
  if (head == tail) {
    int l = fread(buffer, 1, Size, stdin);
    tail = (head = buffer) + l;
  }
  if (head == tail) return -1;
  return *head++;
}
inline int read() {
  int x = 0, f = 1;
  char c = Getchar();
  for (; !isdigit(c); c = Getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = Getchar()) x = x * 10 + c - '0';
  return x * f;
}
inline char readc() {
  char c = Getchar();
  while (c != '-' && c != '+') c = Getchar();
  return c;
}
const int maxn = 100010;
const long long inf = 1ll << 60;
int n, A[maxn], tp[maxn];
long long res, sum[maxn];
int main() {
  n = read();
  res = read();
  for (int i = (2), i_end_ = (n); i <= i_end_; i++) {
    char c = readc();
    A[i] = read();
    if (c == '+')
      tp[i] = 1;
    else
      tp[i] = 0;
  }
  for (int i = (n), i_end_ = (2); i >= i_end_; i--) sum[i] = sum[i + 1] + A[i];
  long long ans = res;
  for (int i = (2), i_end_ = (n); i <= i_end_; i++)
    ans += A[i] * (tp[i] == 1 ? 1 : -1);
  for (int i = (2), i_end_ = (n); i <= i_end_; i++)
    if (!tp[i]) {
      for (int j = (2), j_end_ = (i - 1); j <= j_end_; j++) res += A[j];
      res -= A[i];
      for (int j = (i + 1), j_end_ = (n); j <= j_end_; j++) {
        if (!tp[j]) ans = max(ans, res + sum[j]);
        res -= A[j];
      }
      ans = max(ans, res);
    }
  printf("%lld\n", ans);
  return 0;
}
