#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const int INF = 2147483647;
int n;
int pre[MAX], suf[MAX], a[MAX], minp[MAX], mins[MAX], maxn;
int main() {
  scanf("%d", &n);
  minp[0] = 1;
  mins[n + 1] = n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pre[i] = pre[i - 1] + a[i];
    if (pre[minp[i - 1]] > pre[i])
      minp[i] = i;
    else
      minp[i] = minp[i - 1];
  }
  for (int i = n; i >= 1; i--) {
    suf[i] = suf[i + 1] + a[i];
    if (suf[mins[i + 1]] > suf[i])
      mins[i] = i;
    else
      mins[i] = mins[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    int l = minp[i], r = mins[i];
    if (l == r)
      ans = max(pre[n], -pre[n]);
    else {
      if (pre[l] < 0)
        ans += -pre[l];
      else
        ans += pre[l];
      if (suf[r] < 0)
        ans += -suf[r];
      else
        ans += suf[r];
      ans += pre[r - 1] - pre[l];
    }
    maxn = max(maxn, ans);
  }
  cout << maxn;
  return 0;
}
