#include <bits/stdc++.h>
using namespace std;
const long long maxl = 200005;
long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -w;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = (s << 1) + (s << 3) + (ch ^ '0');
    ch = getchar();
  }
  return s * w;
}
long long n, val;
long long a[maxl], f[maxl][3][2][2];
long long pmt(long long x, long long y) { return ((x - y) % 3 + 3) % 3; }
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    for (long long j = 0; j < 3; j++) {
      for (long long k = 0; k < 2; k++) {
        for (long long w = 0; w < 2; w++) f[i][j][k][w] = -900000000000000007;
      }
    }
  }
  if (n == 1) return cout << a[1] << endl, 0;
  f[1][0][0][0] = a[1];
  f[1][1][0][1] = -a[1];
  for (long long i = 2; i <= n; i++) {
    for (long long j = 0; j < 3; j++) {
      val = pmt(j, 1);
      f[i][j][0][0] = f[i - 1][j][0][1] + a[i];
      f[i][j][0][1] = f[i - 1][val][0][0] - a[i];
      f[i][j][1][0] =
          max(f[i - 1][j][0][0], max(f[i - 1][j][1][0], f[i - 1][j][1][1])) +
          a[i];
      f[i][j][1][1] = max(f[i - 1][val][0][1],
                          max(f[i - 1][val][1][0], f[i - 1][val][1][1])) -
                      a[i];
    }
  }
  val = pmt(1, n);
  cout << max(f[n][val][1][0], f[n][val][1][1]) << endl;
  return 0;
}
