#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> v(n + 1, 0);
  long long val;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<long long> min_pre(n + 1, 0);
  min_pre[0] = v[0] * -1;
  for (int i = 1; i < n; i++) {
    min_pre[i] = min_pre[i - 1] + (v[i] * -1);
  }
  vector<long long> max_pre(n + 1, 0);
  max_pre[0] = max(v[0] * -1, v[0]);
  for (int i = 1; i < n; i++) {
    max_pre[i] = (max_pre[i - 1] + v[i], min_pre[i]);
  }
  vector<long long> min_suf(n + 1, 0);
  min_suf[n - 1] = (v[n - 1] * -1);
  for (int i = n - 2; i >= 0; i--) {
    min_suf[i] = min_suf[i + 1] + (v[i] * -1);
  }
  vector<long long> max_suf(n + 1, 0);
  max_suf[n - 1] = max(v[n - 1], v[n - 1] * -1);
  for (int i = n - 2; i >= 0; i--) {
    max_suf[i] = max(min_suf[i], max_suf[i + 1] + v[i]);
  }
  long long res = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      res = max(max_pre[0] + max_suf[1], max_suf[0]);
      continue;
    }
    if (i == n - 1) {
      res = max(res, max_pre[n - 2] + max_suf[n - 1]);
      res = max(res, max_pre[n - 1]);
      continue;
    }
    res = max(res, max_pre[i] + max_suf[i + 1]);
    res = max(res, max_pre[i - 1] + max_suf[i]);
  }
  cout << res << endl;
  return 0;
}
