#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
int n;
int a[131072];
int best[131072];
int main(void) {
  in = stdin;
  out = stdout;
  fscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) fscanf(in, "%d", &a[i]);
  int sum = 0, bst = 0, ans = 0, other = 0;
  for (int i = 0; i < n; i++) {
    sum -= a[i];
    other += a[i];
    if (bst + other < sum) {
      bst = sum;
      other = 0;
    }
    best[i] = bst + other;
  }
  ans = best[n - 1];
  sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum -= a[i];
    if (i > 0)
      ans = max(ans, sum + best[i - 1]);
    else
      ans = max(ans, sum);
  }
  fprintf(out, "%d\n", ans);
  return 0;
}
