#include <bits/stdc++.h>
using namespace std;
int n, i;
long long f[+200500][3][2][2];
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(0);
  iostream::sync_with_stdio(0);
  int q;
  q = 1;
  while (q--) {
    cin >> n;
    vector<long long> a(n);
    for (i = 0; i < n; i++) cin >> a[i];
    if (n == 1) {
      cout << a[0];
      return 0;
    }
    for (i = 0; i < n; i++)
      for (int sum = 0; sum < 3; sum++)
        for (int last = 0; last < 2; last++)
          for (int was = 0; was < 2; was++) f[i][sum][last][was] = -1e18;
    f[0][1][0][0] = a[0];
    f[0][2][1][0] = -a[0];
    for (i = 0; i < n - 1; i++)
      for (int sum = 0; sum < 3; sum++)
        for (int last = 0; last < 2; last++)
          for (int was = 0; was < 2; was++) {
            if (f[i][sum][last][was] == -1e18) continue;
            for (int nx = 0; nx < 2; nx++) {
              int nsum = sum;
              int nlast = nx;
              int nw = was;
              nsum = (sum + ((nx > 0) ? -1 : 1) + 3) % 3;
              nw |= (last == nx);
              f[i + 1][nsum][nlast][nw] =
                  max(f[i + 1][nsum][nlast][nw],
                      f[i][sum][last][was] + (((nx > 0) ? -1 : 1) * a[i + 1]));
            }
          }
    cout << max(f[n - 1][1][0][1], f[n - 1][1][1][1]) << '\n';
  }
}
