#include <bits/stdc++.h>
using namespace std;
long long n, a, sumo, summ;
vector<int> m, o;
int main() {
  cin >> n;
  if (n == 1) {
    cin >> a;
    cout << a << endl;
    return 0;
  } else if (n == 2) {
    long long x;
    cin >> a >> x;
    cout << max(x, a) - min(x, a) << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a < 0) {
      m.push_back(a);
      summ += -a;
    } else {
      o.push_back(a);
      sumo += a;
    }
  }
  sort(o.begin(), o.end());
  sort(m.begin(), m.end());
  if (!m.size()) {
    long long x = 0;
    sumo -= o[0] + o[o.size() - 1];
    x = o[o.size() - 1] - o[0];
    if (o[0] == o[o.size() - 1]) {
      sumo -= o[o.size() - 2];
      x = o[0];
    }
    cout << sumo + x << endl;
  } else if (!o.size()) {
    long long x = 0;
    summ -= (m[0] + m[m.size() - 1]) * -1;
    x = m[m.size() - 1] - m[0];
    if (m[0] == m[m.size() - 1]) {
      summ -= -m[m.size() - 2];
      x = -m[0];
    }
    cout << summ + x << endl;
  } else {
    cout << summ + sumo << endl;
  }
}
