#include <bits/stdc++.h>
const int MAX_N = 200000;
const long long INF = 1LL << 60;
int v[1 + MAX_N];
long long dp[1 + MAX_N][3][2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 2; ++j) dp[0][i][j] = -INF;
  dp[0][0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &v[i]);
    for (int sum = 0; sum < 3; ++sum)
      for (int cons = 0; cons < 2; ++cons) {
        int sgn = 1;
        dp[i][sum][cons] = -INF;
        for (int t = 1; t <= 2; ++t) {
          dp[i][sum][cons] =
              std::max(dp[i][sum][cons],
                       dp[i - 1][(sum + 3 - t) % 3][cons] + sgn * v[i]);
          sgn = sgn * (-1);
        }
        if (cons == 1 && i >= 2) {
          int sgn = 1;
          for (int t = 1; t <= 2; ++t) {
            dp[i][sum][cons] =
                std::max(dp[i][sum][cons], dp[i - 2][(sum + 6 - 2 * t) % 3][0] +
                                               sgn * (v[i] + v[i - 1]));
            sgn = sgn * (-1);
          }
        }
      }
  }
  if (n == 1)
    printf("%d\n", v[1]);
  else
    printf("%lld", dp[n][1][1]);
  return 0;
}
