#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], pre[N];
int main() {
  int sum = 0, ans;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  ans = sum;
  pre[0] = 0;
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + (-a[i] - a[i]);
  }
  for (int i = 1; i <= n; i++) {
    pre[i] = max(pre[i - 1], pre[i]);
  }
  for (int i = n, suf = 0; i >= 0; i--) {
    ans = max(ans, sum + suf + pre[i]);
    suf += -2 * a[i];
  }
  cout << ans << endl;
  return 0;
}
