#include <bits/stdc++.h>
using namespace std;
int n, a[500010];
long long f[500010][2][2];
void readf() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
}
void solve() {
  if (n == 1) {
    cout << a[1];
    exit(0);
  }
  memset(f, -0x3f, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 2; ++j)
      for (int k = 0; k < 2; ++k)
        if (f[i][j][k] > -1000000000000000) {
          f[i + 1][j | 1][k] = max(f[i + 1][j | 1][k], f[i][j][k] - a[i + 1]);
          f[i + 1][j][k | 1] = max(f[i + 1][j][k | 1], f[i][j][k] + a[i + 1]);
        }
  cout << f[n][1][1];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  readf();
  solve();
}
