#include <bits/stdc++.h>
using namespace std;
long long dp[200005][3][2];
void solve() {
  int n;
  scanf("%d", &n);
  int a[200005];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  if (n == 1) {
    printf("%d\n", a[1]);
    return;
  }
  dp[0][0][1] = -1e18;
  for (int j = 0; j < 3; j++) {
    for (int k = 0; k < 2; k++) {
      dp[0][j][k] = -1e18;
    }
  }
  dp[0][0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 2; k++) {
        dp[i][j][k] = -1e18;
      }
    }
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 2; k++) {
        dp[i][(j + 1) % 3][k] =
            max(dp[i][(j + 1) % 3][k], dp[i - 1][j][k] + a[i]);
        dp[i][(j + 2) % 3][k] =
            max(dp[i][(j + 2) % 3][k], dp[i - 1][j][k] - a[i]);
      }
      if (i >= 2) {
        dp[i][(j + 1) % 3][1] =
            max(dp[i][(j + 1) % 3][1], dp[i - 2][j][0] - a[i - 1] - a[i]);
        dp[i][(j + 2) % 3][1] =
            max(dp[i][(j + 2) % 3][1], dp[i - 2][j][0] + a[i - 1] + a[i]);
      }
    }
  }
  printf("%lld\n", dp[n][1][1]);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
