#include <bits/stdc++.h>
using namespace std;
int val[100005];
char fh[100005];
int n;
long long dp[100005][15];
int main() {
  scanf("%d", &n);
  fh[1] = '+';
  for (int i = 1; i <= n; i++) {
    scanf("%d", val + i);
    if (i != n) {
      scanf(" %c", fh + i + 1);
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < 10; j++) {
      dp[i][j] = -0x3f3f3f3f3f3f3f3fll;
    }
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 10; j++) {
      if (j != 2 && fh[i] == '-') {
        dp[i][j + 1] =
            max(dp[i][j + 1], dp[i - 1][j] + (j == 1 ? 1 : -1) * val[i]);
      }
      if (j) {
        dp[i][j - 1] = max(dp[i][j - 1],
                           dp[i - 1][j] + (j == 2 ? -1 : 1) *
                                              (fh[i] == '-' ? -1 : 1) * val[i]);
      }
      dp[i][j] =
          max(dp[i][j], dp[i - 1][j] + (j % 2 ? -1 : 1) *
                                           (fh[i] == '-' ? -1 : 1) * val[i]);
    }
  }
  printf("%lld\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
  return 0;
}
