#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s * f;
}
const int N = 2e5 + 5;
int n;
long long a[N], f[N][3][2];
inline void chkmax(long long &x, long long y) {
  if (y > x) x = y;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[1];
    return 0;
  }
  memset(f, -0x3f, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 2; k++) {
        chkmax(f[i + 1][(j + 1) % 3][k | ((j + 1) % 3 == 2)],
               f[i][j][k] + a[i + 1]);
        chkmax(f[i + 1][(j + 2) % 3][k | ((j + 2) % 3 == 2)],
               f[i][j][k] - a[i + 1]);
      }
  }
  cout << f[n][1][1];
  return 0;
}
