#include <bits/stdc++.h>
using namespace std;
int n;
long long f[2000005][3][2][2];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 2; k++)
        for (int ij = 0; ij < 2; ij++) f[i][j][k][ij] = -100000000000000;
  scanf("%lld", &f[1][1][0][1]);
  f[1][2][0][0] = -f[1][1][0][1];
  if (n == 1) {
    printf("%lld", f[1][1][0][1]);
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 2; k++)
        for (int ij = 0; ij < 2; ij++) {
          f[i][(j + 1) % 3][k | (ij == 1)][1] =
              max(f[i][(j + 1) % 3][k | (ij == 1)][1], f[i - 1][j][k][ij] + x);
          f[i][(j + 2) % 3][k | (ij == 0)][0] =
              max(f[i][(j + 2) % 3][k | (ij == 0)][0], f[i - 1][j][k][ij] - x);
        }
  }
  printf("%lld", max(f[n][1][1][0], f[n][1][1][1]));
  return 0;
}
