#include <bits/stdc++.h>
using namespace std;
int l[100005], dp1[100005], dp2[100005], a[100005];
int main() {
  int i, n;
  while (~scanf("%d", &n)) {
    l[0] = 0;
    for (i = 1; i <= n; i++) scanf("%d", &a[i]), l[i] = l[i - 1] + a[i];
    int sum = l[n];
    dp1[0] = 0;
    for (i = 1; i <= n; i++) {
      dp1[i] = max(dp1[i - 1] + a[i], -l[i]);
    }
    dp2[n + 1] = 0;
    for (i = n; i >= 1; i--) {
      dp2[i] = max(dp2[i + 1] + a[i], l[i - 1] - sum);
    }
    int ans = -0xfffffff;
    for (i = 1; i <= n; i++) ans = max(ans, dp1[i - 1] + dp2[i]);
    printf("%d\n", ans);
  }
  return 0;
}
