#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  int pref[n + 2];
  pref[0] = 0;
  for (int i = 0; i < n; ++i) {
    pref[i + 1] = pref[i] + a[i];
  }
  int best[n + 2];
  best[0] = 0;
  for (int i = 0; i < n; ++i) {
    best[i + 1] = max(-pref[i + 1], a[i] + best[i]);
  }
  int sum = pref[n];
  int ans = sum;
  for (int i = 0; i <= n; ++i) {
    int res = abs(sum - pref[i]) + best[i];
    ans = max(ans, res);
  }
  printf("%d\n", ans);
  return 0;
}
