#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const int N = 1e6 + 7;
const int M = 1e6 + 7;
long long mod = 1e9 + 7;
long long preMin[N], preMax[N];
long long sufMin[N], sufMax[N];
long long a[N];
signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  preMin[1] = preMax[1] = a[1];
  for (int i = 2; i <= n; i++) {
    preMin[i] = min(preMin[i - 1] - a[i], a[i] - preMax[i - 1]);
    preMax[i] = max(preMax[i - 1] - a[i], a[i] - preMin[i - 1]);
    preMin[i] = min(preMin[i], a[i] + preMin[i - 1]);
    preMax[i] = max(preMax[i], a[i] + preMax[i - 1]);
  }
  sufMin[n] = sufMax[n] = a[n];
  for (int i = n - 1; i; i--) {
    sufMin[i] = min(sufMin[i + 1] - a[i], a[i] - sufMax[i + 1]);
    sufMax[i] = max(sufMax[i + 1] - a[i], a[i] - sufMin[i + 1]);
    sufMin[i] = min(sufMin[i], a[i] + sufMin[i + 1]);
    sufMax[i] = max(sufMax[i], a[i] + sufMax[i + 1]);
  }
  long long ans = max(a[1] - sufMin[2], a[n] - preMin[n - 1]);
  for (int i = 2; i < n; i++)
    ans = max(ans, a[i] - sufMin[i + 1] - preMin[i - 1]);
  cout << ans << "\n";
  return 0;
}
