#include <bits/stdc++.h>
using namespace std;
int a[100002], h[100002], t[100002];
int main() {
  int n, S = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    S += a[i];
  }
  int hProf = 0, tProf = 0;
  for (int i = 1; i <= n; i++) {
    hProf -= 2 * a[i];
    tProf -= 2 * a[n - i + 1];
    h[i] = max(h[i - 1], hProf);
    t[n - i + 1] = max(t[n - i + 2], tProf);
  }
  int MAX = INT_MIN, x;
  for (int i = 0; i < n; i++) {
    x = S + h[i] + t[i + 1];
    if (MAX < x) MAX = x;
  }
  cout << MAX;
  return 0;
}
