#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int n;
int ara[200005];
long long dp[200005][3][2][2];
bool pri[200005][3][2][2];
long long cnt(int i, int ald, int a, int b) {
  if (i == n + 1) {
    if ((n + ald) % 3 != 1) return -INF;
    if (!b) return -INF;
    return 0;
  }
  long long &res = dp[i][ald][a][b];
  if (pri[i][ald][a][b]) return res;
  pri[i][ald][a][b] = true;
  res = ara[i] + cnt(i + 1, ald, 1, b | a);
  res = max(res, -ara[i] + cnt(i + 1, (ald + 1) % 3, 0, b | (!a)));
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", ara + i);
  if (n == 1) {
    printf("%d\n", ara[1]);
    return 0;
  }
  long long ans = ara[1] + cnt(2, 0, 1, 0);
  ans = max(ans, -ara[1] + cnt(2, 1, 0, 0));
  printf("%lld\n", ans);
  return 0;
}
