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