#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0, sum = 99999999999999, tmp = 9999999999999;
  scanf("%d", &ans);
  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)
      sum = min(sum, tmp), tmp = x;
    else
      tmp += x;
    ans += x;
  }
  cout << ans - sum * 2 << endl;
  return 0;
}
