#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[200005];
long long dp[200005][3][2][2];
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[1] << endl;
    return 0;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          dp[i][j][k][l] = -1e18;
        }
      }
    }
  }
  dp[0][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++) {
        for (int l = 0; l < 2; l++) {
          for (int m = 0; m < 2; m++) {
            long long nj = j, nk = k, sgn = 1;
            if (i >= 1 && l == m) nk = 1;
            if (m == 0)
              nj += 2;
            else
              nj += 1, sgn = -1;
            (dp[i + 1][nj % 3][nk][m]) = max((dp[i + 1][nj % 3][nk][m]),
                                             (dp[i][j][k][l] + sgn * a[i + 1]));
          }
        }
      }
    }
  }
  long long ans = max(dp[n][2][1][0], dp[n][2][1][1]);
  cout << ans << endl;
  return 0;
}
