#include <bits/stdc++.h>
using namespace std;
int _v[4 * (int)(1e5) + 1000];
void insert(int v, int l, int r, int i) {
  if (l == r)
    _v[v]++;
  else {
    int mid = (l + r) / 2;
    if (i <= mid)
      insert(2 * v, l, mid, i);
    else
      insert(2 * v + 1, mid + 1, r, i);
    _v[v] = _v[2 * v] + _v[2 * v + 1];
  }
}
int query(int v, int lv, int rv, int l, int r) {
  if (l > r) return 0;
  if (lv == l and rv == r) return _v[v];
  int mv = (lv + rv) / 2;
  return query(2 * v, lv, mv, l, min(r, mv)) +
         query(2 * v + 1, mv + 1, rv, max(mv + 1, l), r);
}
int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> nums(N);
  for (int i = (0); i <= (N - 1); i++) cin >> nums[i];
  vector<long long> rmaxsum(N + 1);
  rmaxsum[N] = 0;
  long long rsum = 0;
  for (int i = N - 1; i >= 0; i--) {
    rsum += nums[i];
    rmaxsum[i] = max(-rsum, nums[i] + rmaxsum[i + 1]);
  }
  long long maxsum = rmaxsum[0];
  long long sum = 0;
  for (int i = (0); i <= (N - 1); i++) {
    sum += -nums[i];
    maxsum = max(maxsum, sum + rmaxsum[i + 1]);
  }
  cout << maxsum << endl;
  return 0;
}
