#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  int sum = 0;
  int c;
  int ans = 0;
  int k = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    sum += c;
    k += c;
    if (k < 0) k = 0;
    ans = max(ans, k);
  }
  cout << -sum + ans * 2;
}
