#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long INF = 1e16;
long long f[N][3], g[N][3];
int a[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  if (n == 1) {
    printf("%d\n", a[1]);
    return 0;
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j < 3; ++j) f[i][j] = g[i][j] = -INF;
  g[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 3; ++j) {
      f[i][j] = max(f[i - 1][j] + a[i], f[i - 1][(j - 1 + 3) % 3] - a[i]);
      g[i][j] = max(g[i - 1][j] + a[i], g[i - 1][(j - 1 + 3) % 3] - a[i]);
      if (i >= 2) {
        f[i][j] = max(f[i][j], g[i - 2][j] + a[i - 1] + a[i]);
        f[i][j] = max(f[i][j], g[i - 2][(j - 2 + 3) % 3] - a[i - 1] - a[i]);
      }
    }
  }
  printf("%lld\n", f[n][(1 - n % 3 + 3) % 3]);
}
