#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 * 1000 + 5;
int n;
int a[maxn];
int dpP[maxn], dpS[maxn];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int sum = a[0];
  dpP[0] = abs(a[0]);
  for (int i = 1; i < n; ++i) {
    sum += a[i];
    dpP[i] = max(dpP[i - 1] + a[i], abs(sum));
  }
  sum = a[n - 1];
  dpS[n - 1] = abs(a[n - 1]);
  for (int i = n - 2; i >= 0; --i) {
    sum += a[i];
    dpS[i] = max(dpS[i + 1] + a[i], abs(sum));
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) ans = max(ans, dpP[i] + dpS[i + 1]);
  cout << ans << endl;
  return 0;
}
