#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int *dp = new int[n];
  int mi = 0;
  int cur = 0;
  int temp = 0;
  int ans = INT_MIN;
  for (int i = 0; i < n; i++) {
    scanf("%d", &temp);
    cur += temp;
    mi = min(mi, cur);
    ans = max(cur - mi, ans);
  }
  cout << 2 * ans - cur << endl;
}
