#include <bits/stdc++.h>
using namespace std;
int n;
int lleft[2][100001];
int rright[2][100001];
int a[100001];
int main() {
  memset(lleft, 0, sizeof(lleft));
  memset(rright, 0, sizeof(rright));
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  lleft[1][0] = -a[0];
  lleft[0][0] = a[0];
  rright[1][n - 1] = -a[n - 1];
  rright[0][n - 1] = a[n - 1];
  for (int i = 1; i < n; i++) {
    lleft[1][i] = lleft[1][i - 1] - a[i];
    lleft[0][i] = max(lleft[1][i - 1] + a[i], lleft[0][i - 1] + a[i]);
  }
  for (int i = n - 2; i >= 0; i--) {
    rright[1][i] = rright[1][i + 1] - a[i];
    rright[0][i] = max(rright[1][i + 1] + a[i], rright[0][i + 1] + a[i]);
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 != n)
      res = max(res, max(lleft[0][i], lleft[1][i]) +
                         max(rright[0][i + 1], rright[1][i + 1]));
    else
      res = max(res, max(lleft[0][i], lleft[1][i]));
  }
  cout << res << endl;
  return 0;
}
