#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, min_i, max_i;
  long mini = 10e9, maxi = -10e9;
  long a[500005];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mini) {
      mini = a[i];
      min_i = i;
    }
    if (a[i] >= maxi) {
      maxi = a[i];
      max_i = i;
    }
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (i != max_i && i != min_i) sum += (long long)abs(a[i]);
  }
  if (max_i == min_i)
    cout << maxi << endl;
  else
    cout << (long long)maxi + sum - (long long)mini << endl;
}
