#include <bits/stdc++.h>
using namespace std;
int n, i, ans, a[100010], sum1[100010], sum2[100010];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) sum1[i] = sum1[i - 1] + a[i];
  for (i = n; i >= 1; i--) sum2[i] = sum2[i + 1] + a[i];
  for (i = 1; i <= n; i++) sum1[i] = max(abs(sum1[i]), sum1[i - 1] + a[i]);
  for (i = 1; i <= n; i++) sum2[i] = max(abs(sum2[i]), sum2[i + 1] + a[i]);
  for (i = 1; i <= n; i++) ans = max(ans, sum1[i] + sum2[i + 1]);
  cout << ans;
  return 0;
}
