#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[100003];
  int l[100003];
  int r[100003];
  int res = 0;
  l[n + 1] = r[n + 1] = a[n + 1] = l[0] = r[0] = a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    res += a[i];
  }
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    cur -= a[i];
    l[i] = max(cur, l[i - 1] + a[i]);
  }
  cur = 0;
  for (int i = n; i >= 1; i--) {
    cur -= a[i];
    r[i] = max(cur, r[i + 1] + a[i]);
  }
  for (int i = 0; i <= n + 1; i++) res = max(l[i] + r[i + 1], res);
  cout << res << endl;
  return 0;
}
