#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int((a)[(n)]);
  for (int i = 0; i < (n); i++) cin >> ((a)[i]);
  int sm = 0;
  for (int(i) = 0; (i) < (n); (i)++) sm += a[i];
  int mn = 0, ans = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    mn += a[i];
    if (mn < 0) mn = 0;
    ans = max(ans, mn);
  }
  cout << 2 * ans - sm << "\n";
  return 0;
}
