#include <bits/stdc++.h>
using namespace std;
class Point {
 public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(x * a, y * a); }
  Point operator/(double a) { return Point(x / a, y / a); }
  double absv() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const Point &p) const {
    return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
  }
};
struct Segment {
  Point p1, p2;
};
double hen(Point a) {
  if (fabs(a.x) < (1e-10) && a.y > 0)
    return acos(0);
  else if (fabs(a.x) < (1e-10) && a.y < 0)
    return 3 * acos(0);
  else if (fabs(a.y) < (1e-10) && a.x < 0)
    return 2 * acos(0);
  else if (fabs(a.y) < (1e-10) && a.x > 0)
    return 0.0;
  else if (a.y > 0)
    return acos(a.x / a.absv());
  else
    return 2 * acos(0) + acos(-a.x / a.absv());
}
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long gcd(long long v, long long b) {
  if (v > b) return gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return gcd(v, b % v);
}
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double distans(double x1, double y1, double x2, double y2) {
  double rr = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  return sqrt(rr);
}
void no() {
  cout << "No" << endl;
  return;
}
long long beki(long long r, long long k) {
  if (k == 0)
    return 1;
  else
    return r * beki(r, k - 1);
}
long long a[100010];
long long op[100010];
long long dp[100010][3];
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < 100010; i++)
    for (long long j = 0; j < 3; j++) dp[i][j] = -1000000007 * 10000000ll;
  for (long long i = 0; i < n - 1; i++) {
    long long dd;
    string sa;
    cin >> dd >> sa;
    a[i + 1] = dd;
    if (sa == "+")
      op[i + 1] = 1;
    else
      op[i + 1] = -1;
  }
  cin >> a[n];
  op[0] = 1;
  dp[0][0] = 0;
  for (long long i = 1; i <= n; i++) {
    if (op[i - 1] == 1) {
      dp[i][0] = max(dp[i][0], dp[i - 1][0] + a[i]);
      dp[i][0] = max(dp[i][0], dp[i - 1][1] + a[i]);
      dp[i][1] = max(dp[i][1], dp[i - 1][1] - a[i]);
      dp[i][1] = max(dp[i][1], dp[i - 1][2] - a[i]);
      dp[i][2] = max(dp[i][2], dp[i - 1][2] + a[i]);
    } else {
      dp[i][0] = max(dp[i][0], dp[i - 1][0] - a[i]);
      dp[i][0] = max(dp[i][0], dp[i - 1][1] - a[i]);
      dp[i][1] = max(dp[i][1], dp[i - 1][0] - a[i]);
      dp[i][1] = max(dp[i][1], dp[i - 1][1] + a[i]);
      dp[i][1] = max(dp[i][1], dp[i - 1][2] + a[i]);
      dp[i][2] = max(dp[i][2], dp[i - 1][1] + a[i]);
      dp[i][2] = max(dp[i][2], dp[i - 1][2] - a[i]);
    }
  }
  cout << max(dp[n][0], dp[n][1]) << endl;
  return 0;
}
