#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
long long n, pos, cnt, Tmp = 1e10, tmp = -1e10, t, a[N];
bool check, taken[N];
queue<long long> Q;
void Input() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] >= 0) pos = i, cnt++;
    if (a[i] < 0) Q.push(i), check = true;
    if (tmp < a[i]) tmp = a[i], t = i;
    if (Tmp > a[i]) Tmp = a[i];
  }
}
void Solve() {
  if (check == false) {
    long long sum = 0;
    for (int i = 1; i <= n; i++) sum += a[i];
    cout << sum - 2 * Tmp << '\n';
  } else if (pos == 0) {
    long long sum = a[t];
    for (int i = t - 1; i >= 1; i--) sum = sum - a[i];
    for (int i = t + 1; i <= n; i++) sum = sum - a[i];
    cout << sum << '\n';
  } else {
    long long sum = 0;
    while (!Q.empty()) {
      int p = Q.front();
      Q.pop();
      sum += abs(a[p]);
      for (int i = p - 1; i >= 1; i--) {
        if (taken[i] || a[i] < 0 || cnt <= 1) break;
        sum += a[i], cnt--;
        taken[i] = true;
      }
      for (int i = p + 1; i <= n; i++) {
        if (taken[i] || a[i] < 0 || cnt <= 1) break;
        sum += a[i], cnt--;
        taken[i] = true;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (!taken[i] && a[i] >= 0) {
        cout << a[i] + sum << '\n';
        return;
      }
    }
  }
}
int main() {
  Input();
  if (n == 1)
    cout << a[1] << '\n';
  else
    Solve();
  return 0;
}
