#include <bits/stdc++.h>
int a[100000];
int main() {
  int n, i, j, max, sum, total, x, ans;
  scanf("%d", &n);
  n--;
  scanf("%d", &x);
  total = sum = x;
  max = 0;
  if (x > 0) max = x;
  for (i = 0; i < n; i++) {
    if (sum < 0) sum = 0;
    scanf("%d", &x);
    total += x;
    sum += x;
    if (sum > max) max = sum;
  }
  ans = max - (total - max);
  printf("%d\n", ans);
  return 0;
}
