#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 20;
long long readin() {
  long long x = 0, f = 1;
  char op = getchar();
  while (op < '0' || op > '9') {
    if (op == '-') f = -1;
    op = getchar();
  }
  while (op >= '0' && op <= '9') {
    x = x * 10 + op - '0';
    op = getchar();
  }
  return x * f;
}
int n, a[maxn];
long long dp[maxn][3][2];
int change[4][2] = {1, 1, -1, -1, 1, -1, -1, 1};
int num[4] = {2, 4, 3, 3};
int main() {
  n = readin();
  for (int i = 1; i <= n; ++i) {
    a[i] = readin();
  }
  if (n == 1)
    cout << a[1] << endl;
  else {
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j < 3; ++j) {
        for (int k = 0; k < 2; ++k) {
          dp[i][j][k] = LONG_LONG_MIN;
        }
      }
    }
    dp[0][0][0] = 0;
    dp[1][1][0] = a[1];
    dp[1][2][0] = -a[1];
    for (int i = 2; i <= n; ++i) {
      for (int j = 0; j < 3; ++j) {
        for (int d = 0; d < 4; ++d) {
          long long f = a[i - 1] * change[d][0], g = a[i] * change[d][1];
          for (int k = 0; k < 2; ++k) {
            if (dp[i - 2][j][k] != LONG_LONG_MIN) {
              if (d < 2)
                dp[i][(j + num[d]) % 3][1] =
                    max(dp[i][(j + num[d]) % 3][1], dp[i - 2][j][k] + f + g);
              else
                dp[i][(j + num[d]) % 3][k] =
                    max(dp[i][(j + num[d]) % 3][k], dp[i - 2][j][k] + f + g);
            }
          }
        }
        if (dp[i - 1][j][1] != LONG_LONG_MIN) {
          dp[i][(j + 1) % 3][1] =
              max(dp[i][(j + 1) % 3][1], dp[i - 1][j][1] + a[i]);
          dp[i][(j + 2) % 3][1] =
              max(dp[i][(j + 2) % 3][1], dp[i - 1][j][1] - a[i]);
        }
      }
    }
    cout << dp[n][1][1] << endl;
  }
  return 0;
}
