#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') y = -y;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * y;
}
namespace qiqi {
const int N = 2e5 + 5;
int n;
long long a[N], f[N][3][2];
void main() {
  n = read();
  if (n == 1) {
    printf("%lld\n", read());
    return;
  }
  for (int i = (1); i <= (n); ++i) a[i] = read();
  for (int i = (0); i <= (2); ++i)
    for (int j = (0); j <= (1); ++j) f[0][i][j] = -1e18;
  f[0][0][0] = 0;
  for (int i = (1); i <= (n); ++i)
    for (int j = (0); j <= (2); ++j) {
      for (int k = (0); k <= (1); ++k)
        f[i][j][k] = max(f[i - 1][(j + 2) % 3][k] + a[i],
                         f[i - 1][(j + 1) % 3][k] - a[i]);
      if (i > 1)
        f[i][j][1] =
            max(f[i][j][1], max(f[i - 2][(j + 1) % 3][0] + a[i] + a[i - 1],
                                f[i - 2][(j + 2) % 3][0] - a[i] - a[i - 1]));
    }
  printf("%lld\n", f[n][1][1]);
}
}  // namespace qiqi
int main() {
  qiqi::main();
  return 0;
}
