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