#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n, arr[N], preSum[N], sufSum[N], preMax[N], sufMax[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &arr[i]), preSum[i] = preSum[i - 1] + arr[i];
  for (int i = n; i >= 1; i--) sufSum[i] = sufSum[i + 1] + arr[i];
  for (int i = 1; i <= n; i++)
    preMax[i] = max(preMax[i - 1] + arr[i], -preSum[i]);
  for (int i = n; i >= 1; i--)
    sufMax[i] = max(sufMax[i + 1] + arr[i], -sufSum[i]);
  int out = -1e9;
  for (int i = 0; i <= n; i++) out = max(out, preMax[i] + sufMax[i + 1]);
  printf("%d\n", out);
}
