#include <bits/stdc++.h>
using namespace std;
int n, num[100005], pre[100005], suff[100005], m[100005];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> num[i];
  pre[0] = 0;
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + num[i];
  suff[n + 1] = 0;
  for (int i = n; i > 0; i--) suff[i] = suff[i + 1] + num[i];
  if (suff[n] <= 0)
    m[n] = n;
  else
    m[n] = n + 1;
  for (int i = n - 1; i > 0; i--)
    if (suff[i] < suff[m[i + 1]])
      m[i] = i;
    else
      m[i] = m[i + 1];
  int ans = -1000000000;
  for (int i = 0; i < n; i++) {
    int temp = m[i + 1];
    ans = max(ans, pre[temp - 1] - pre[i] * 2 - suff[temp]);
  }
  cout << ans << endl;
  return 0;
}
