#include <bits/stdc++.h>
using namespace std;
const int maxN = (2e5) + 5;
int n, x;
long long sol = LLONG_MIN;
pair<int, int> v[maxN];
int p[maxN];
long long sp[maxN];
inline void updateSol(int pos, int neg) {
  long long val = 0;
  val = sp[pos] - (sp[n] - sp[pos]);
  sol = max(sol, val);
}
inline int abs(int x) { return x > 0 ? x : -x; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    v[i] = make_pair(x, i);
  }
  if (n == 1) {
    printf("%d\n", v[1].first);
    return 0;
  }
  sort(v + 1, v + n + 1);
  reverse(v + 1, v + n + 1);
  for (int i = 1; i <= n; i++) sp[i] = sp[i - 1] + 1LL * v[i].first;
  int y = 0;
  while ((y + n) % 3 != 1) y++;
  for (int neg = y; neg <= n; neg += 3) {
    int pos = n - neg;
    if (abs(pos - neg) > 1) {
      updateSol(pos, neg);
      continue;
    }
    for (int i = 1; i <= pos; i++) p[v[i].second] = 1;
    for (int i = pos + 1; i <= n; i++) p[v[i].second] = -1;
    bool ok = 0;
    for (int i = 1; i < n; i++)
      if (p[i] == p[i + 1]) ok = 1;
    if (ok == 1)
      updateSol(pos, neg);
    else {
      long long val = 0;
      for (int i = 1; i < pos; i++) val += 1LL * v[i].first;
      val += 1LL * v[pos + 1].first;
      for (int i = pos + 2; i <= n; i++) val -= 1LL * v[i].first;
      val -= 1LL * v[pos].first;
      sol = max(sol, val);
    }
  }
  printf("%lld\n", sol);
  return 0;
}
