#include <bits/stdc++.h>
using namespace std;
int a[100009], dp[100009][4];
string s[100009];
int main() {
  for (int i = 0; i < 100009; i++)
    for (int j = 0; j < 4; j++) dp[i][j] = -(1e8);
  int ans, n;
  cin >> n >> ans;
  n--;
  for (int i = 0; i < n; i++) cin >> s[i] >> a[i];
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == "+") {
      dp[i + 1][0] = dp[i][0] + a[i];
      dp[i + 1][1] = dp[i][1] - a[i];
      dp[i + 1][2] = dp[i][2] + a[i];
    } else {
      dp[i + 1][0] = max(dp[i][0] - a[i], dp[i][2] + a[i]);
      dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] - a[i]);
      dp[i + 1][2] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
    }
  }
  cout << ans + max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}
