#include <bits/stdc++.h>
using namespace std;
template <class T>
void max_self(T& a, const T& b) {
  if (a < b) a = b;
}
template <class T>
void min_self(T& a, const T& b) {
  if (a > b) a = b;
}
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);
int N, total = 0, suff = 0, sub = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> N;
  for (int rep = 0, x; rep < N; ++rep) {
    cin >> x;
    total += x;
    suff = max(suff + x, x);
    max_self(sub, suff);
  }
  assert(total <= sub);
  total = sub + (total - sub) * -1;
  cout << total << '\n';
  return 0;
}
