#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 7;
int a[N], s[N];
int n, sum, ans;
signed main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i) scanf("%d", a + i), sum += a[i];
  for (register int i = n; i; --i) s[i] = s[i + 1] + a[i];
  for (register int i = 1; i <= n; ++i) a[i] += a[i - 1];
  for (register int i = n; i; --i) s[i] = (s[i + 1] < s[i] ? s[i + 1] : s[i]);
  ans = sum;
  for (register int i = 0; i <= n; ++i)
    ans = (sum - ((a[i] + s[i + 1]) << 1) > ans ? sum - ((a[i] + s[i + 1]) << 1)
                                                : ans);
  printf("%d", ans);
  return 0;
}
