#include <bits/stdc++.h>
using namespace std;
char op[3005];
int n, a[3005], ans, dp[3005][3005], mx;
int main() {
  scanf("%d\n", &n);
  scanf("%d ", &a[0]);
  for (int i = (1); i <= (n - 1); ++i) scanf("%c %d ", &op[i], &a[i]);
  for (int i = (1); i <= (n - 1); ++i) printf("%c %d\n", op[i], a[i]);
  ans = -1e9;
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (n - 1); ++j) dp[i][j] = -1e9;
  dp[0][0] = 0;
  for (int i = (1); i <= (n - 1); ++i) {
    if (op[i] == '+') {
      int now = -1e9;
      for (int j = (mx); j >= (0); --j) {
        now = max(now, dp[i - 1][j] + a[i] * (j & 1 ? -1 : 1));
        dp[i][j] = now;
      }
    } else {
      mx++;
      dp[i][0] = dp[i - 1][0] - a[i];
      for (int j = (1); j <= (mx); ++j)
        dp[i][j] = max(dp[i - 1][j] + a[i] * (j & 1 ? 1 : -1),
                       dp[i - 1][j - 1] + a[i] * (j & 1 ? -1 : 1));
    }
  }
  for (int i = (0); i <= (mx); ++i) ans = max(ans, dp[n - 1][i]);
  printf("%d\n", ans + a[0]);
  return 0;
}
