#include <bits/stdc++.h>
using ll = long long;
using pii = std::pair<int, int>;
using vi = std::vector<int>;
using vii = std::vector<pii>;
using std::cin;
using std::cout;
using std::sort;
using std::string;
using std::vector;
static constexpr int DX[4] = {1, 0, -1, 0};
static constexpr int DY[4] = {0, 1, 0, -1};
static constexpr int MOD = 1000000007;
static int powm(int x, int n) {
  int r = 1;
  while (n) {
    if (n & 1) r = (r * 1LL * x) % MOD;
    x = (x * 1LL * x) % MOD;
    n /= 2;
  }
  return r;
}
static int inv(int x) { return powm(x, MOD - 2); }
static void chmax(int& x, int y) { x = std::max(x, y); }
static void chmax(ll& x, ll y) { x = std::max(x, y); }
static constexpr int N = 1 << 18;
const ll inf = (ll)1e18;
void solve() {
  int n;
  scanf("%d", &n);
  ll dp[3][2] = {{0, -inf}, {-inf, -inf}, {-inf, -inf}};
  ll value;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &value);
    ll dd[3][2] = {{-inf, -inf}, {-inf, -inf}, {-inf, -inf}};
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 2; ++k) {
        int p;
        p = k;
        if ((j + 1) % 3 == 2) p = 1;
        chmax(dd[(j + 1) % 3][p], dp[j][k] + value);
        p = k;
        if ((j + 2) % 3 == 2) p = 1;
        chmax(dd[(j + 2) % 3][p], dp[j][k] - value);
      }
    }
    memcpy(dp, dd, sizeof(dp));
  }
  if (n == 1) dp[1][1] = value;
  printf("%lld\n", dp[1][1]);
}
int main(int argc, char* argv[]) {
  ::std::ios::sync_with_stdio(false);
  ::std::cin.tie(0);
  ::std::cout.tie(0);
  int tc = 1;
  for (int i = 1; i <= tc; ++i) {
    solve();
  }
  return 0;
}
