#include <bits/stdc++.h>
using namespace std;
long long n, a[200015], dp[200015][3][2][2];
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  memset(dp, -0x3f, sizeof dp);
  if (n == 1) {
    printf("%lld\n", a[1]);
    return 0;
  }
  dp[1][2][0][0] = -a[1];
  dp[1][1][1][0] = a[1];
  for (long long i = 1; i <= n - 1; i++) {
    for (long long j = 0; j <= 2; j++) {
      dp[i + 1][(j + 1) % 3][1][1] =
          max(dp[i + 1][(j + 1) % 3][1][1],
              max({dp[i][j][1][1], dp[i][j][1][0], dp[i][j][0][1]}) + a[i + 1]);
      dp[i + 1][(j + 1) % 3][1][0] =
          max(dp[i][j][0][0] + a[i + 1], dp[i + 1][(j + 1) % 3][1][0]);
      dp[i + 1][(j + 2) % 3][0][1] =
          max(dp[i + 1][(j + 2) % 3][0][1],
              max({dp[i][j][0][0], dp[i][j][0][1], dp[i][j][1][1]}) - a[i + 1]);
      dp[i + 1][(j + 2) % 3][0][0] =
          max(dp[i][j][1][0] - a[i + 1], dp[i + 1][(j + 2) % 3][0][0]);
    }
  }
  printf("%lld\n", max(dp[n][1][0][1], dp[n][1][1][1]));
  return 0;
}
