#include <bits/stdc++.h>
using namespace std;
int ns[100002];
int sm1[100002], dp1[100002];
int sm2[100002], dp2[100002];
int main() {
  int n, res = -2000000000;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &ns[i]);
  }
  sm1[0] = dp1[0] = 0;
  for (int i = 1; i <= n; ++i) {
    sm1[i] = sm1[i - 1] + ns[i];
    dp1[i] = dp1[i - 1] + ns[i] > -sm1[i] ? dp1[i - 1] + ns[i] : -sm1[i];
  }
  sm2[n + 1] = dp2[n + 1] = 0;
  for (int i = n; i >= 1; --i) {
    sm2[i] = sm2[i + 1] + ns[i];
    dp2[i] = dp2[i + 1] + ns[i] > -sm2[i] ? dp2[i + 1] + ns[i] : -sm2[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (dp1[i] + dp2[i + 1] > res) {
      res = dp1[i] + dp2[i + 1];
    }
  }
  printf("%d\n", res);
  return 0;
}
