#include <bits/stdc++.h>
using namespace std;
int a[100010];
long long s[100010];
int main(void) {
  int N, i;
  scanf("%d", &N);
  for ((i) = 0; (i) < (int)(N); (i)++) scanf("%d", &a[i]);
  for ((i) = 0; (i) < (int)(N); (i)++) s[i + 1] = s[i] + a[i];
  long long tmp = 0, ans = 0;
  for (i = N; i >= 0; i--) {
    tmp = max(tmp, -2 * (s[N] - s[i]));
    ans = max(ans, s[N] - 2 * s[i] + tmp);
  }
  cout << ans << endl;
  return 0;
}
