#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<pair<long long, long long> > p;
  for (int i = 0; i < n; i++) p.push_back({a[i], i});
  sort(p.begin(), p.end());
  set<pair<long long, long long> > toques;
  for (int i = 1; i < n; i++) toques.insert({i, i - 1});
  if (n == 1) cout << a[0] << '\n', exit(0);
  if (n == 2) cout << -a[0] - a[1] << '\n', exit(0);
  set<int> puestos;
  bool f = false;
  long long s = 0;
  for (int i = 0; i < n; i++) s += a[i];
  long long res = -2e18, k = 0;
  for (int i = 0; i < n; i++) {
    if ((n + k) % 3 == 1) {
      if (!((int)toques.size()) && !f)
        s += 2 * a[p[i - 1].second] - 2 * a[p[i].second];
      res = max(res, s);
      if (!((int)toques.size()) && !f)
        s -= 2 * a[p[i - 1].second] - 2 * a[p[i].second];
    }
    s -= 2 * a[p[i].second];
    auto it = puestos.insert(p[i].second).first;
    if (it != puestos.begin() && *prev(it) == p[i].second - 1) f = true;
    if (next(it) != puestos.end() && *next(it) == p[i].second + 1) f = true;
    toques.erase({p[i].second, p[i].second - 1});
    toques.erase({p[i].second + 1, p[i].second});
    k++;
  }
  cout << res << '\n';
}
