#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long int inf = 1e18, M = 1e9 + 7;
const long long int N = 1;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; ++i) cin >> v[i];
  vector<long long int> sum(n + 1, 0), suf(n + 1, 0), need(n + 1, 0);
  for (long long int i = 0; i < n; ++i) sum[i + 1] = sum[i] + v[i];
  for (long long int i = n - 1; i >= 0; --i) suf[i] = suf[i + 1] - v[i];
  for (long long int i = 0; i < n + 1; ++i) need[i] = sum[i] + suf[i];
  multiset<long long int> ms;
  for (long long int i = 0; i < n + 1; ++i) ms.insert(need[i]);
  long long int ans = *ms.rbegin();
  long long int pre = 0;
  for (long long int i = 0; i < n; ++i) {
    pre += v[i];
    ms.erase(ms.find(need[i]));
    ans = max(ans, *ms.rbegin() - 2ll * pre);
  }
  cout << ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
