#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int((a)[(n)]);
  for (int i = 0; i < (n); i++) cin >> ((a)[i]);
  int st[n + 1];
  st[0] = 0;
  int cur = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    cur += a[i];
    st[i + 1] = cur;
  }
  for (int(i) = 0; (i) < (n); (i)++) st[i + 1] = min(st[i + 1], st[i]);
  int en[n + 1];
  en[n] = 0;
  cur = 0;
  for (int i = n - 1; i >= 0; i--) {
    cur += a[i];
    en[i] = cur;
  }
  for (int i = n - 1; i >= 0; i--) en[i] = min(en[i], en[i + 1]);
  int ans = 0;
  for (int(i) = 0; (i) < (n + 1); (i)++) ans = min(ans, en[i] + st[i]);
  int sum = 0;
  for (int(i) = 0; (i) < (n); (i)++) sum += a[i];
  cout << sum - 2 * ans << "\n";
  return 0;
}
