#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 66;
int a[MAXN];
int sfx[MAXN], sum[MAXN];
int main() {
  int n, i;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
    sum[i] = a[i];
    if (i) sum[i] += sum[i - 1];
  }
  sfx[0] = 0;
  for (i = 1; i <= n; ++i) {
    sfx[i] = max(sfx[i - 1] + a[i - 1], -sum[i - 1]);
  }
  int ans = sfx[n], prfx = 0;
  for (i = n - 1; i >= 0; --i) {
    prfx += -a[i];
    ans = max(ans, prfx + sfx[i]);
  }
  cout << ans;
  return 0;
}
