#include <bits/stdc++.h>
using namespace std;
const int MN = 100 * 1000 + 20;
int a[MN], dl[MN], dr[MN], dp[MN];
int main() {
  int n, sum = 0, m1i = 0, m1j = 0, m2i = 0, m2j = 0, m, ans;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
  dl[0] = 0;
  for (int i = 1; i <= n; i++) dl[i] = dl[i - 1] - 2 * a[i];
  dr[n + 1] = 0;
  for (int i = n; i >= 1; i--) dr[i] = dr[i + 1] - 2 * a[i];
  dp[0] = dl[0];
  for (int i = 1; i <= n; i++) dp[i] = max(dp[i - 1], dl[i]);
  ans = dr[1] + dp[0];
  for (int i = 1; i <= n + 1; i++) ans = max(ans, dr[i] + dp[i - 1]);
  cout << sum + ans << endl;
  return 0;
}
