#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, ans = 0, x, sump = 0, sumn = 0;
  int n;
  cin >> n;
  vector<int> dp1n(n);
  vector<int> dp1p(n);
  vector<int> dp2n(n);
  vector<int> dp2p(n);
  vector<int> arr;
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
    sump += x;
    sumn += -1 * x;
  }
  ans = max(sump, ans);
  ans = max(sumn, ans);
  dp1n[0] = -1 * arr[0];
  dp1p[0] = arr[0];
  for (int i = 1; i < n; i++) {
    dp1n[i] = dp1n[i - 1] + -1 * arr[i];
    dp1p[i] = max(dp1n[i - 1], dp1p[i - 1]) + arr[i];
  }
  dp2n[n - 1] = -1 * arr[n - 1];
  dp2p[n - 1] = arr[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    dp2n[i] = dp2n[i + 1] + -1 * arr[i];
    dp2p[i] = max(dp2n[i + 1], dp2p[i + 1]) + arr[i];
  }
  for (int i = 0; i < n; i++) {
    ans = max(ans, dp2p[i] + dp1p[i] - arr[i]);
  }
  cout << ans << endl;
  return 0;
}
