#include <bits/stdc++.h>
const int kN = 2e5 + 10;
int n, a[kN];
long long f[kN][3][2][2];
inline int read() {
  int f = 1, w = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) w = (w << 3) + (w << 1) + (ch ^ '0');
  return f * w;
}
void Chkmax(long long &fir, long long sec) {
  if (sec > fir) fir = sec;
}
void Chkmin(int &fir, int sec) {
  if (sec < fir) fir = sec;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  if (n == 1) {
    printf("%d\n", a[1]);
    return 0;
  }
  memset(f, 128, sizeof(f));
  f[1][1][1][0] = a[1];
  f[1][1 + 1][0][0] = -a[1];
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j <= 2; ++j) {
      for (int k = 0; k <= 1; ++k) {
        for (int l = 0; l <= 1; ++l) {
          Chkmax(f[i][(j + 1) % 3][1][l | (k == 1)], f[i - 1][j][k][l] + a[i]);
          Chkmax(f[i][(j + 1 + 1) % 3][0][l | (k == 0)],
                 f[i - 1][j][k][l] - a[i]);
        }
      }
    }
  }
  printf("%lld\n", std::max(f[n][1][0][1], f[n][1][1][1]));
  return 0;
}
