#include <bits/stdc++.h>
using namespace std;
int n, sum, tmp, ans, a[100010];
int main(int argc, char *argv[]) {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    tmp = sum = ans = 0;
    for (int i = 0; i < n; ++i) {
      tmp += a[i];
      sum += a[i];
      if (sum < 0) sum = 0;
      ans = sum > ans ? sum : ans;
    }
    printf("%d\n", 2 * ans - tmp);
  }
  return 0;
}
