#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e5 + 5;
long long n, a[INF], ans, ansx, b[INF], suma[INF], l[INF], r[INF];
long long read() {
  long long s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = (s << 1) + (s << 3) + (ch ^ 48);
    ch = getchar();
  }
  return s * f;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    b[i] = a[i];
    suma[i] = suma[i - 1] + a[i];
  }
  for (long long i = 1; i <= n; i++) l[i] = max(l[i - 1] + a[i], -suma[i]);
  for (long long i = n; i >= 1; i--)
    r[i] = max(r[i + 1] + a[i], -(suma[n] - suma[i - 1]));
  for (long long i = 0; i <= n; i++) ans = max(ans, l[i] + r[i + 1]);
  write(ans);
  return 0;
}
