#include <bits/stdc++.h>
using namespace std;
long long a[100050], n, ans, sum, MAX, s;
int main() {
  std::cin >> n;
  for (long long i = 1; i <= n; i++) {
    std::cin >> a[i];
    sum += a[i];
  }
  for (long long i = 1; i <= n; i++)
    if (s + a[i] < 0)
      s = 0;
    else
      s += a[i], MAX = max(MAX, s);
  MAX = max(MAX, s);
  ans = MAX * 2 - sum;
  std::cout << ans;
  return 0;
}
