#include <bits/stdc++.h>
using namespace std;
int a[1000000], b[1000000], s[1000000];
int main() {
  int n;
  cin >> n;
  cin >> a[0];
  s[0] = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    s[i] = a[i] + s[i - 1];
  }
  if (s[0] < 0)
    b[0] = -s[0];
  else
    b[0] = s[0];
  for (int i = 1; i < n; i++) {
    if (-s[i] > b[i - 1] + a[i])
      b[i] = -s[i];
    else
      b[i] = b[i - 1] + a[i];
  }
  int mx = -10000000;
  for (int i = n - 1; i >= 0; i--) {
    int p = s[n - 1] - s[i];
    p *= -1;
    p += b[i];
    if (p > mx) mx = p;
  }
  cout << mx;
  return 0;
}
