#include <bits/stdc++.h>
using namespace std;
const long long NEGINF = -(long long)1e15 + 696969;
long long n;
long long A[200011];
long long dp[200011][3][2][2];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> A[i];
  if (n == 1) {
    cout << A[0] << endl;
    return 0;
  }
  for (long long k = 0; k < 3; k++) {
    for (long long s = 0; s < 2; s++) {
      for (long long o = 0; o < 2; o++) {
        long long res = NEGINF;
        if (k == 1 and o == 1) res = s ? -A[n - 1] : A[n - 1];
        dp[n - 1][k][s][o] = res;
      }
    }
  }
  for (long long i = n - 2; i >= 0; i--) {
    for (long long k = 0; k < 3; k++) {
      for (long long s = 0; s < 2; s++) {
        for (long long o = 0; o < 2; o++) {
          long long res = NEGINF;
          res = max(res, dp[i + 1][k][0][o | (s == 0)]);
          res = max(res, dp[i + 1][(k + 1) % 3][1][o | (s == 1)]);
          dp[i][k][s][o] = res + (s ? -A[i] : A[i]);
        }
      }
    }
  }
  cout << max(dp[0][n % 3][0][0], dp[0][(n + 1) % 3][1][0]) << endl;
  return 0;
}
