#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
long long arr[N];
int n;
int main() {
  scanf("%d", &n);
  long long mint = 0x7f7f7f7f, maxt = -0x7f7f7f7f;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    ans += abs(arr[i]);
    mint = min(mint, arr[i]);
    maxt = max(maxt, arr[i]);
  }
  if (n == 1)
    printf("%lld\n", arr[0]);
  else if (n == 2)
    printf("%lld\n", max(arr[0] - arr[1], arr[1] - arr[0]));
  else {
    if (mint > 0)
      ans -= 2 * mint;
    else if (maxt < 0)
      ans -= 2 * abs(maxt);
    printf("%lld\n", ans);
  }
  return 0;
}
