#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500000 + 10;
const int INF = numeric_limits<int>::max();
const int EPS = 1e-6;
long long a[MAXN], pref[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  bool negative = false, positive = false, zero = false;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] < 0) {
      negative = true;
    }
    if (a[i] > 0) {
      positive = true;
    }
    if (a[i] == 0) {
      zero = true;
    }
    if (i > 0)
      pref[i] = pref[i - 1] + abs(a[i]);
    else
      pref[i] = abs(a[i]);
  }
  if (n == 1) {
    cout << a[0] << endl;
    return 0;
  }
  long long ans = 0;
  if (zero || !zero && negative && positive) {
    ans = pref[n - 1];
  } else if (positive || negative) {
    for (int i = 1; i < n; ++i) {
      ans = max(ans, (i == 1 ? 0ll : pref[i - 2]) + (pref[n - 1] - pref[i]) +
                         abs(a[i] - a[i - 1]));
    }
  }
  cout << ans << endl;
  return 0;
}
