#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int a, b, c, d, i, j, n, m, k, ans;
int cs[100001], mas[100001], dp[100001];
inline int sum(int a, int b) {
  if (!a)
    return cs[b];
  else
    return cs[b] - cs[a - 1];
}
int main() {
  scanf("%d", &n);
  for (int _n((n)-1), i(0); i <= _n; i++) {
    scanf("%d", &mas[i]);
    if (!i)
      cs[i] = mas[i];
    else
      cs[i] = cs[i - 1] + mas[i];
  }
  ans = -1000000000 - 1;
  for (int _n((n)-1), i(0); i <= _n; i++) {
    if (!i)
      dp[i] = max(cs[i], -cs[i]);
    else
      dp[i] = max(dp[i - 1] + mas[i], max(cs[i], -cs[i]));
    ans = max(ans, dp[i]);
  }
  a = 0;
  for (int i = (n - 2), _b = (0); i >= _b; i--) {
    a += mas[i + 1];
    ans = max(ans, max(a, -a) + dp[i]);
  }
  ans = max(ans, cs[n - 1]);
  ans = max(ans, -cs[n - 1]);
  ans = max(ans, dp[n - 1]);
  printf("%d\n", ans);
}
