#include <bits/stdc++.h>
using namespace std;
int A[100000];
int M[100000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> A[i];
  if (n == 1) return cout << abs(A[0]) << endl, 0;
  M[n - 1] = abs(A[n - 1]);
  int sum = A[n - 1];
  for (int i = n - 2; i > 0; --i) {
    sum += A[i];
    M[i] = max(-sum, M[i + 1] + A[i]);
  }
  sum = 0;
  M[0] = abs(A[0]);
  int ans = M[0] + M[1];
  for (int i = 0; i < n - 1; ++i) {
    sum += A[i];
    M[i] = max(-sum, M[i - 1] + A[i]);
    ans = max(ans, M[i] + M[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
