#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
char c;
int a[N];
bool b[N];
long long s[N], sa[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i < n) {
      c = getchar();
      while (c != '-' && c != '+') c = getchar();
      if (c == '-')
        b[i + 1] = true;
      else
        b[i + 1] = false;
    }
  }
  for (int i = n; i >= 1; i--) sa[i] = sa[i + 1] + a[i];
  for (int i = 1; i <= n; i++)
    if (b[i]) a[i] = -a[i];
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
  long long ans = s[n];
  int last = 0;
  for (int i = 1; i <= n; i++)
    if (b[i]) {
      if (last) {
        ans = max(ans, s[last] - (sa[last + 1] - sa[i]) + sa[i]);
      } else
        last = i;
    }
  cout << ans << endl;
}
