#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  int n;
  scanf("%d", &n);
  int S = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    S += a[i];
  }
  int mx = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum < 0) sum = 0;
    mx = max(mx, sum);
  }
  printf("%d\n", 2 * mx - S);
  return 0;
}
