#include <bits/stdc++.h>
using namespace std;
vector<int> vec;
int sum[100000 + 5], sum2[100000 + 5], a[100000 + 5], n;
bool dec[100000 + 5];
char str[5];
int main() {
  scanf("%d", &n);
  scanf("%d", &a[1]);
  for (int i = 2; i <= n; i++) {
    scanf("%s %d", str, &a[i]);
    if (str[0] == '-') vec.push_back(i), dec[i] = true;
  }
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  for (int i = 1; i <= n; i++)
    if (dec[i] == true)
      sum2[i] = sum2[i - 1] - a[i];
    else
      sum2[i] = sum2[i - 1] + a[i];
  int ans = sum2[n], pos1, pos2;
  for (int i = 0; i < (int)vec.size() - 1; i++) {
    pos1 = vec[i], pos2 = vec[i + 1];
    ans = max(ans, sum2[pos1] - (sum[pos2 - 1] - sum[pos1]) +
                       (sum[n] - sum[pos2 - 1]));
  }
  printf("%d\n", ans);
  return 0;
}
