#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  static char c;
  int f = 0;
  while (!isdigit(c = getchar()))
    if (c == '-') f = 1;
  x = c ^ 48;
  while (isdigit(c = getchar())) x = (x * 10) + (c ^ 48);
  if (f) x = -x;
}
void read(long long &x) {
  static char c;
  int f = 0;
  while (!isdigit(c = getchar()))
    if (c ^ 45) f = 1;
  x = c ^ 48;
  while (isdigit(c = getchar())) x = (x * 10) + (c ^ 48);
}
void read(unsigned int &x) {
  static char c;
  while (!isdigit(c = getchar()))
    ;
  x = c ^ 48;
  while (isdigit(c = getchar())) x = (x * 10) + (c ^ 48);
}
void read(unsigned long long &x) {
  static char c;
  while (!isdigit(c = getchar()))
    ;
  x = c ^ 48;
  while (isdigit(c = getchar())) x = (x * 10) + (c ^ 48);
}
void chkmax(int &x, int y) {
  if (y > x) x = y;
}
void chkmin(int &x, int y) {
  if (y < x) x = y;
}
void chkmax(long long &x, long long y) {
  if (y > x) x = y;
}
void chkmin(long long &x, long long y) {
  if (y < x) x = y;
}
void chkmax(unsigned int &x, unsigned int y) {
  if (y > x) x = y;
}
void chkmin(unsigned int &x, unsigned int y) {
  if (y < x) x = y;
}
void chkmax(unsigned long long &x, unsigned long long y) {
  if (y > x) x = y;
}
void chkmin(unsigned long long &x, unsigned long long y) {
  if (y < x) x = y;
}
const int N = 2e5 + 10;
const long long Inf = 1e16;
int n;
int A[N];
long long F[N][3][2][2];
void Work() {
  read(n);
  for (int i = 1; i <= n; ++i) read(A[i]);
  if (n == 1) return printf("%d\n", A[1]), void();
  for (int i = 1; i <= n; ++i)
    for (int R : {0, 1, 2})
      for (int L : {0, 1})
        for (int S : {0, 1}) F[i][R][L][S] = -Inf;
  F[1][1][0][0] = -A[1], F[1][0][1][0] = A[1];
  for (int i = 2; i <= n; ++i)
    for (int R : {0, 1, 2})
      for (int L : {0, 1})
        for (int S : {0, 1})
          chkmax(F[i][R][1][S | L], F[i - 1][R][L][S] + A[i]),
              chkmax(F[i][(R + 1) % 3][0][S | (L ^ 1)],
                     F[i - 1][R][L][S] - A[i]);
  printf("%lld\n",
         max(F[n][(4 - n % 3) % 3][0][1], F[n][(4 - n % 3) % 3][1][1]));
}
int main() { Work(); }
