#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const long long oo = 1 << 30;
const long long loo = 1ll << 62;
const long long mods = 1e9 + 7;
const long long MAXN = 200005;
const long long INF = 0x3f3f3f3f;
inline long long read() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
long long f[MAXN][3], s[MAXN], a[MAXN];
signed main() {
  long long ans = -loo;
  f[0][0] = 0, f[0][1] = f[0][2] = -loo;
  long long n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  if (n == 1) {
    printf("%d\n", a[1]);
    return 0;
  }
  for (long long i = n; i >= 1; i--)
    s[i] = s[i + 1] + a[i] * (((n - i + 1) & 1) ? 1 : -1);
  for (long long i = 1; i <= n; i++) {
    f[i][0] = f[i - 1][2] + a[i], f[i][1] = f[i - 1][0] + a[i],
    f[i][2] = f[i - 1][1] + a[i];
    upmax(f[i][0], f[i - 1][1] - a[i]);
    upmax(f[i][1], f[i - 1][2] - a[i]);
    upmax(f[i][2], f[i - 1][0] - a[i]);
    if (i < n)
      if ((n - i) & 1) {
        upmax(ans, f[i - 1][2] + a[i] + s[i + 1]);
        upmax(ans, f[i - 1][0] - a[i] - s[i + 1]);
      } else {
        upmax(ans, f[i - 1][0] + a[i] - s[i + 1]);
        upmax(ans, f[i - 1][2] - a[i] + s[i + 1]);
      }
  }
  printf("%lld\n", ans);
  return 0;
}
