#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long c = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    c = c * 10 + ch - '0';
    ch = getchar();
  }
  return c * f;
}
const int N = 2e5 + 10;
long long dp[N][3][3], a[N];
int main() {
  int n = read();
  for (int i = 1; i < n + 1; ++i) a[i] = read();
  memset(dp, -0x3f, sizeof dp);
  dp[1][1][2] = -a[1];
  dp[1][0][1] = a[1];
  for (int i = 2; i < n + 1; ++i) {
    for (int j = 0; j < 3; ++j) {
      dp[i][(j + 1) % 3][0] =
          max(dp[i][(j + 1) % 3][0], dp[i - 1][j][0] - a[i]);
      dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][0] + a[i]);
      if (i & 1) {
        dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][1] + a[i]);
        dp[i][(j + 1) % 3][0] =
            max(dp[i][(j + 1) % 3][0], dp[i - 1][j][1] - a[i]);
        dp[i][(j + 1) % 3][2] =
            max(dp[i][(j + 1) % 3][2], dp[i - 1][j][2] - a[i]);
        dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][2] + a[i]);
      } else {
        dp[i][(j + 1) % 3][1] =
            max(dp[i][(j + 1) % 3][1], dp[i - 1][j][1] - a[i]);
        dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][1] + a[i]);
        dp[i][j][2] = max(dp[i][j][2], dp[i - 1][j][2] + a[i]);
        dp[i][(j + 1) % 3][0] =
            max(dp[i][(j + 1) % 3][0], dp[i - 1][j][2] - a[i]);
      }
    }
  }
  if (n == 1)
    for (int j = 0; j < 3; ++j) {
      dp[n][j][0] = max(dp[n][j][0], dp[n][j][1]);
      dp[n][j][0] = max(dp[n][j][0], dp[n][j][2]);
    }
  printf("%lld", dp[n][(4 - n % 3) % 3][0]);
}
