#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, t, j = 0, x = 0;
  cin >> n;
  int s[100008] = {0};
  bool k[100008] = {0};
  char r[500008] = {0};
  long long int a[100008] = {0};
  int b = 0;
  getchar();
  gets(r);
  for (i = 0; r[i] != 0; i++) {
    if (isdigit(r[i]))
      s[j++] = r[i] - '0';
    else if (r[i] == ' ')
      continue;
    else if (r[i] == '+')
      k[x++] = 1;
    else if (r[i] == '-')
      k[x++] = 0;
  }
  a[b++] = s[0];
  bool ka[100008] = {0};
  int bka = 0;
  for (i = 0; i < x; i++) {
    if (k[i] == 1) {
      a[b++] = s[i + 1];
      ka[bka++] = 1;
    }
    if (k[i] == 0 && k[i + 1] == 0) {
      int y;
      ka[bka++] = 0;
      long long int yy = s[i + 1];
      for (y = i + 1; y <= x; y++) {
        if (k[y] == 0) yy -= s[y + 1];
      }
      a[b++] = yy;
      i--;
      i = y;
    }
    if (k[i] == 0) {
      a[b++] = s[i + 1];
      ka[bka++] = 0;
    }
  }
  if (k[x - 2] != 0) {
    if (k[x - 1] == 0) {
      a[b++] = s[i + 1];
      ka[bka++] = 0;
    }
    if (k[x - 1] == 1) {
      a[b++] = s[i + 1];
      ka[bka++] = 1;
    }
  }
  long long int m = a[0];
  long long int q = m;
  for (i = 0; i < bka; i++) {
    if (ka[i] == 0) q -= a[i + 1];
    if (ka[i] == 1) q += a[i + 1];
    m = max(q, m);
  }
  cout << m << endl;
  return 0;
}
