#include <bits/stdc++.h>
using namespace std;
int n, ans = -2e9, a[100005], pre[100005], suff[100005], mnsuff[100005],
       mnid[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  mnid[n + 1] = n + 1;
  for (int i = 1; i <= n; ++i) cin >> a[i], pre[i] = pre[i - 1] + a[i];
  for (int i = n; i; --i) {
    suff[i] = suff[i + 1] + a[i];
    mnsuff[i] = mnsuff[i + 1];
    mnid[i] = mnid[i + 1];
    if (suff[i] < mnsuff[i]) mnid[i] = i, mnsuff[i] = suff[i];
  }
  for (int i = 0; i <= n; ++i) {
    int ps = pre[i], sffs = suff[mnid[i + 1]],
        imp = pre[mnid[i + 1] - 1] - pre[i];
    if (ps < 0) ps = -ps;
    if (sffs < 0) sffs = -sffs;
    ans = max(ans, ps + sffs + imp);
  }
  cout << ans;
}
