#include <bits/stdc++.h>
using namespace std;
int a, sum, tmp, t;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    sum += a;
    t += a;
    if (t < 0) t = 0;
    if (t > tmp) tmp = t;
  }
  cout << tmp - sum + tmp << endl;
  return 0;
}
