#include <bits/stdc++.h>
using namespace std;
int n;
int a[100000 + 10];
int main() {
  priority_queue<int, vector<int>, less<int> > q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int sum = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  int ans = sum, Sum = sum;
  q.push(0);
  for (int i = n - 1; i >= 0; i--) {
    sum -= a[i];
    sum2 += a[i];
    q.push(-2 * sum2);
    ans = max(ans, -2 * sum + q.top() + Sum);
  }
  printf("%d\n", ans);
  return 0;
}
