#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
int v[MAX_N], vpref[MAX_N + 1][2], vsuff[MAX_N + 1][2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
  for (int k = 0; k < 2; ++k) vpref[0][k] = 0, vsuff[n][k] = 0;
  for (int i = 1; i <= n; ++i) {
    vpref[i][1] = vpref[i - 1][1] - v[i - 1];
    vpref[i][0] = max(vpref[i - 1][0], vpref[i - 1][1]) + v[i - 1];
  }
  for (int i = n - 1; i >= 0; --i) {
    vsuff[i][1] = vsuff[i + 1][1] - v[i];
    vsuff[i][0] = max(vsuff[i + 1][0], vsuff[i + 1][1]) + v[i];
  }
  int best = INT_MIN;
  for (int i = 0; i <= n; ++i) {
    const int pref = max(vpref[i][0], vpref[i][1]);
    const int suff = max(vsuff[i][0], vsuff[i][1]);
    best = max(best, pref + suff);
  }
  printf("%d\n", best);
  return 0;
}
