#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int left_mx[N];
int right_mx[N];
int a[N];
int n;
int main() {
  cin >> n;
  int lmx = 0, rmx = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    lmx = min<int>(lmx, sum);
    left_mx[i] = lmx;
  }
  int SUM = sum;
  sum = 0;
  for (int j = n - 1; j >= 0; j--) {
    sum += a[j];
    rmx = min<int>(rmx, sum);
    right_mx[j] = rmx;
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    mx = min<int>(left_mx[i] + right_mx[i + 1], mx);
  }
  cout << max<int>(-SUM, SUM - 2 * mx) << endl;
  return 0;
}
