#include <bits/stdc++.h>
using namespace std;
int n, sum, ans, qwq, a;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    sum += a;
    ans = max(ans + a, 0);
    qwq = max(qwq, ans);
  }
  printf("%d", 2 * qwq - sum);
}
