#include <bits/stdc++.h>
using namespace std;
int n;
int a[100001];
int sum;
int ans1, ans2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 1; i <= n; i++) {
    ans1 = max(ans1 + a[i], 0);
    ans2 = max(ans2, ans1);
  }
  cout << ans2 * 2 - sum;
  return 0;
}
