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