#include <bits/stdc++.h>
using namespace std;
void loadData(void);
int proc(void);
void printRes(int);
int n;
int a[100000];
int main(int argc, char** argv) {
  loadData();
  printRes(proc());
  return 0;
}
int proc(void) {
  int sum = 0;
  for (int i = 0; i < n; i++) sum += a[i];
  int max_seq = 0;
  int temp = 0;
  for (int i = 0; i < n; i++) {
    temp += a[i];
    if (temp < 0) temp = 0;
    max_seq = max(max_seq, temp);
  }
  return 2 * max_seq - sum;
}
void loadData(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  return;
}
void printRes(int res) {
  printf("%d\n", res);
  return;
}
