#include <bits/stdc++.h>
using namespace std;
void observe() {
  set<pair<int, int>> st;
  vector<pair<int, int>> res;
  priority_queue<tuple<int, int, int>> que;
  st.insert(make_pair(1, 0));
  que.push(make_tuple(-1, 1, 0));
  res.push_back(make_pair(1, 0));
  while (!que.empty()) {
    int a, b;
    tie(ignore, a, b) = que.top();
    que.pop();
    if ((a + b) > 20) break;
    cerr << a + b << " : " << a << " ? " << b << endl;
    int sz = res.size();
    for (int i = 0; i < sz; ++i) {
      int c, d;
      tie(c, d) = res[i];
      c += a;
      d += b;
      swap(c, d);
      pair<int, int> cur = {c, d};
      if (st.count(cur)) continue;
      st.insert(cur);
      res.push_back(cur);
      que.emplace(-(c + d), c, d);
    }
  }
  exit(0);
}
const long long inf = 1e18;
long long dp[3][2][2], tmp[3][2][2];
void upd(long long& var, long long val) {
  if (var < val) var = val;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  if (n == 1) {
    printf("%d\n", a[0]);
    return 0;
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 2; ++k) {
        dp[i][j][k] = -inf;
      }
    }
  }
  dp[1][0][1] = a[0];
  dp[0][0][0] = -a[0];
  for (int i = 1; i < n; ++i) {
    for (int r = 0; r < 3; ++r) {
      for (int ok = 0; ok < 2; ++ok) {
        for (int last = 0; last < 2; ++last) {
          tmp[r][ok][last] = dp[r][ok][last];
          dp[r][ok][last] = -inf;
        }
      }
    }
    for (int r = 0; r < 3; ++r) {
      for (int ok = 0; ok < 2; ++ok) {
        for (int last = 0; last < 2; ++last) {
          if (tmp[r][ok][last] <= -inf) continue;
          long long cur = tmp[r][ok][last];
          upd(dp[(r + 1) % 3][ok | (last == 1)][1], cur + a[i]);
          upd(dp[r][ok | (last == 0)][0], cur - a[i]);
        }
      }
    }
  }
  int r = (2 - n) % 3;
  if (r < 0) r += 3;
  printf("%lld\n", max(dp[r][1][0], dp[r][1][1]));
  return 0;
}
