#include <bits/stdc++.h>
using namespace std;
long long int n, ar[100001], max_s[100001], max_e[100001], pre_s[100001],
    pre_e[100001], ans = INT_MIN;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ar[i];
  for (int i = 1; i < n; i++) pre_s[i] = pre_s[i - 1] + ar[i - 1];
  for (int i = n - 2; i >= 0; i--) pre_e[i] = pre_e[i + 1] + ar[i + 1];
  max_e[n - 1] = abs(ar[n - 1]);
  max_s[0] = abs(ar[0]);
  for (int i = n - 2; i >= 0; i--)
    max_e[i] = max(ar[i] + max_e[i + 1], -(ar[i] + pre_e[i]));
  for (int i = 1; i < n; i++)
    max_s[i] = max(ar[i] + max_s[i - 1], -(ar[i] + pre_s[i]));
  ans = max(ans, max_e[0]);
  ans = max(ans, max_s[n - 1]);
  for (int i = 0; i < n - 1; i++) ans = max(ans, max_s[i] + max_e[i + 1]);
  cout << ans;
  return 0;
}
