#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
int a[100009];
void solve() {
  int n, i, tot = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    tot += a[i];
  }
  int ans = 0, sum = 0;
  for (i = 1; i <= n; i++) {
    sum += a[i];
    ans = max(ans, sum);
    sum = max(0, sum);
  }
  tot = 2 * ans - tot;
  cout << tot;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
