#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 3;
int a[maxn], b[maxn], c[maxn], sum;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    ans += a[i];
    cnt -= a[i];
    b[i] = max(max(cnt, ans), b[i - 1] + a[i]);
  }
  ans = 0, cnt = 0;
  for (int i = n; i > 0; i--) {
    ans += a[i];
    cnt -= a[i];
    c[i] = max(max(cnt, ans), c[i + 1] + a[i]);
  }
  int mx = 0;
  for (int i = 0; i <= n; i++) mx = max(c[i + 1] + b[i], mx);
  cout << mx;
}
