#include <bits/stdc++.h>
using namespace std;
double eps = 1e-6;
double pi = acos(0.0) * 2;
double dinf = 1e250;
long long INF = static_cast<long long>(2e18);
int inf = static_cast<int>(1e9 + 7);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T>
void OUT(T a) {
  cout << a;
  exit(0);
}
long long extgcd(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = extgcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> in(n);
  long long res = 0;
  long long summ = 0;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    summ += abs(in[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    long long cursum = summ;
    cursum -= abs(in[i]);
    cursum -= abs(in[i + 1]);
    cursum += abs(in[i] - in[i + 1]);
    res = max(res, cursum);
  }
  if (n == 1)
    cout << in[0];
  else
    cout << res;
  return 0;
}
