#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, a, b;
  bool flag_p = false, flag_n = false;
  cin >> n;
  long long arr[n];
  long long maxx = 0.0;
  long long summ = 0.0;
  for (i = 0; i < n; ++i) {
    cin >> arr[i];
    if (arr[i] < 0) flag_n = true;
    if (arr[i] > 0) flag_p = true;
  }
  if (n == 1) {
    cout << arr[0] << endl;
    return 0;
  }
  if (flag_p == false) {
    for (i = 0; i < n; ++i) arr[i] *= -1;
  }
  for (i = 0; i < n; ++i) {
    summ += abs(arr[i]);
  }
  maxx = summ;
  if (flag_n == false || flag_p == false) {
    maxx = summ - arr[0] - arr[1] + abs(arr[0] - arr[1]);
    for (i = 1; i < n - 1; ++i) {
      a = summ - arr[i] - arr[i - 1] + abs(arr[i] - arr[i - 1]);
      b = summ - arr[i] - arr[i + 1] + abs(arr[i] - arr[i + 1]);
      maxx = max(maxx, max(a, b));
    }
    maxx = max(maxx,
               summ - arr[n - 1] - arr[n - 2] + abs(arr[n - 1] - arr[n - 1]));
  }
  cout << maxx << endl;
}
