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