#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n;
int main() {
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int cur = 0, best = 0;
  for (int i = 0; i < n; i++) {
    cur += a[i];
    if (cur < 0) cur = 0;
    if (cur > best) best = cur;
  }
  cout << best - (sum - best) << endl;
  return 0;
}
