#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long ans1 = 0, sum = 99999999999999, tmp = 0, ans2 = 0;
  scanf("%d", &ans1);
  bool book = false;
  ans2 = ans1;
  for (int i = 1; i < n; ++i) {
    bool flag = false;
    char ch = getchar();
    int x = 0;
    for (; !isdigit(ch); ch = getchar()) flag |= (ch == '-');
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    if (flag) {
      if (book) sum = min(sum, tmp);
      tmp = x;
      book ^= 1;
    } else if (book)
      tmp += x;
    ans1 += x;
    ans2 += flag ? -x : x;
  }
  if (sum == 99999999999999 && !book) sum = 0;
  cout << max(ans1 - sum * 2, ans2) << endl;
  return 0;
}
