#include <bits/stdc++.h>
inline long long sbt(long long x) { return __builtin_popcount(x); }
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long res, ms[100003], mpr[100003];
long long a[100003], pre[100003], suf[100003], n;
int32_t main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  pre[0] = 0;
  for (long long i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + a[i - 1];
    mpr[i] = min(pre[i], mpr[i - 1]);
  }
  suf[n] = 0;
  for (long long i = n - 1; i >= 0; i--) {
    suf[i] = suf[i + 1] + a[i];
    ms[i] = min(suf[i], ms[i + 1]);
  }
  long long maxi = 0;
  for (long long i = 1; i <= n; i++) {
    maxi = max(maxi, -2 * (ms[i] + mpr[i]));
  }
  cout << suf[0] + maxi;
  return 0;
}
