#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n;
  cin >> n;
  vector<long long> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];
  if (n == 1) {
    cout << arr[0] << '\n';
    return 0;
  }
  vector<vector<vector<long long>>> dp(
      2, vector<vector<long long>>(2, vector<long long>(2, -1e17)));
  dp[0][0][0] = 0;
  for (int i = 0; i < n; ++i) {
    vector<vector<vector<long long>>> nxtdp(
        2, vector<vector<long long>>(2, vector<long long>(2, -1e17)));
    for (int previous = 0; previous < 2; ++previous) {
      for (int resolved = 0; resolved < 2; ++resolved) {
        for (int compressed = 0; compressed < 2; ++compressed) {
          for (int current = 0; current < 2; ++current) {
            long long val = current ? arr[i] : -arr[i];
            long long cand = dp[previous][resolved][compressed] + val;
            if (current != previous) {
              if (i != n - 1 || compressed)
                nxtdp[current][resolved][compressed] =
                    max(nxtdp[current][resolved][compressed], cand);
            } else {
              nxtdp[resolved][!resolved][1] =
                  max(nxtdp[resolved][!resolved][1], cand);
            }
          }
        }
      }
    }
    dp = nxtdp;
  }
  cout << max(dp[1][0][0], dp[1][0][1]) << '\n';
}
