#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 5e2 + 10;
int solve(vector<int>& v) {
  int sum = 0;
  int tot = 0;
  int maxv = 0;
  for (auto& x : v) {
    tot += x;
    sum = max(x, sum + x);
    maxv = max(maxv, sum);
  }
  return maxv + abs(tot - maxv);
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto& x : v) cin >> x;
  cout << max(solve(v), solve(v)) << endl;
  return 0;
}
