#include <bits/stdc++.h>
using namespace std;
const long long llinf = 2e18 + 7;
const int inf = 2e9 + 7;
const long long mod = 1e9 + 7;
const long long N = 1e6 + 7;
const long double pi = 3.14159265358979;
void solve() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  long long sum = 0;
  vector<long long> pref(n), suf(n), pcal(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
    pref[i] = sum;
  }
  sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += arr[i];
    suf[i] = sum;
  }
  long long maxx = -inf;
  long long tt = sum;
  for (int i = 0; i < n; i++) {
    maxx = max(maxx, tt - 2 * pref[i]);
    pcal[i] = maxx;
  }
  for (int i = n - 1; i >= 0; i--) {
    maxx = max(maxx, tt - 2 * suf[i]);
  }
  for (int i = n - 1; i >= 1; i--) {
    long long val = pcal[i - 1] - 2 * suf[i];
    maxx = max(maxx, val);
  }
  cout << max(tt, maxx);
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
