#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n + 1);
  int min = 0;
  int max = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
    v[i] += v[i - 1];
    if (v[i] < min) min = v[i];
    if (v[i] - min > max) max = v[i] - min;
  }
  cout << max * 2 - v[n];
  return 0;
}
