#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, arr[100009], kkiri[100009], kknan[100009], idxmin[100009], temp,
      valmin, imin;
  scanf("%d", &N);
  temp = 0;
  kkiri[0] = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &arr[i]);
    temp += arr[i];
    kkiri[i] = temp;
  }
  kkiri[N + 1] = temp;
  kknan[0] = temp;
  for (int i = 1; i <= N; i++) {
    kknan[i] = temp - kkiri[i - 1];
  }
  kknan[N + 1] = 0;
  imin = N + 1;
  valmin = 0;
  idxmin[N + 1] = imin;
  for (int i = N; i >= 1; --i) {
    if (kknan[i] < valmin) {
      valmin = kknan[i];
      imin = i;
    }
    idxmin[i] = imin;
  }
  idxmin[0] = imin;
  for (int i = 0; i <= N; ++i) {
    temp = kkiri[idxmin[i + 1] - 1] - 2 * kkiri[i] - kknan[idxmin[i + 1]];
    if ((temp > valmin) || (i == 0)) valmin = temp;
  }
  printf("%d\n", valmin);
  return 0;
}
