#include <bits/stdc++.h>
int main() {
  int n, i, s = 0, m = 0, t;
  int a[100001];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", a + i);
    s += a[i];
  }
  t = a[0];
  if (t > m) m = t;
  for (i = 1; i < n; i++) {
    if (t > 0)
      t += a[i];
    else
      t = a[i];
    if (t > m) m = t;
  }
  printf("%d\n", 2 * m - s);
  return 0;
}
