#include <bits/stdc++.h>
using namespace std;
const int N = 3e2 + 10, N2 = 1e5 + 10;
int n, arr[N2], pos[N2], neg[N2], ans = -1e9 - 10;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", arr + i);
    neg[i] = -arr[i] + neg[i - 1];
  }
  int onhands = 0, finals = 0;
  for (int i = n + 1; i > 0; i--) {
    onhands += arr[i];
    if (onhands < 0) {
      finals -= onhands;
      onhands = 0;
    }
    ans = max(ans, finals + onhands + neg[i - 1]);
  }
  printf("%d\n", ans);
  return 0;
}
