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