#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int n;
int a[811100];
long long dp[811100][3][3][3];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (n == 1) {
    printf("%d\n", max(a[0], -a[0]));
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 2; ++k)
        for (int l = 0; l < 2; ++l) dp[i][j][k][l] = -1e16;
    }
  }
  dp[0][0][0][0] = a[0];
  dp[0][1][1][0] = -a[0];
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 2; ++k) {
        for (int l = 0; l < 2; ++l) {
          if (dp[i - 1][j][k][l] > -1e16) {
            dp[i][j][0][l | (k == 0)] =
                max(dp[i][j][0][l | (k == 0)], dp[i - 1][j][k][l] + a[i]);
            dp[i][(j + 1) % 3][1][l | (k == 1)] = max(
                dp[i][(j + 1) % 3][1][l | (k == 1)], dp[i - 1][j][k][l] - a[i]);
          }
        }
      }
    }
  }
  cout << max(dp[n - 1][((1 - n) % 3 + 3) % 3][1][1],
              dp[n - 1][((1 - n) % 3 + 3) % 3][0][1])
       << endl;
}
