#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int m1 = -1000000000;
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s = s + arr[i];
  }
  int dp1 = 0;
  int dp2 = 0;
  for (int i = 0; i < n; i++) {
    m1 = max(max(dp1, dp2) - s, m1);
    dp2 = max(dp1, dp2) + arr[i];
    dp1 = dp1 - arr[i];
    s -= arr[i];
  }
  m1 = max(max(dp1, dp2) - s, m1);
  cout << m1 << endl;
}
