#include <bits/stdc++.h>
namespace fastIO {
template <typename T>
inline T read() {
  T f = 1, x = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
template <typename T>
inline void write(T x) {
  if (!x) {
    putchar('0');
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
}  // namespace fastIO
using namespace std;
using fastIO ::write;
namespace fastOutput {
inline void print_array1(int *a, int n) {
  for (int(i) = (1); (i) <= (n); ++(i)) write(a[i]), putchar(" \n"[i == n]);
}
inline void print_array2(int *a, int n) {
  write(n), puts("");
  print_array1(a, n);
}
inline void special_print_array1(int *a, int n) {
  write(n), putchar(' ');
  print_array1(a, n);
}
inline void print_string_in_range(string s, int l, int r) {
  for (int(i) = (l); (i) <= (r); ++(i)) putchar(s[i]);
}
inline void print_chars_in_range(char *a, int l, int r) {
  for (int(i) = (l); (i) <= (r); ++(i)) putchar(a[i]);
}
}  // namespace fastOutput
using fastOutput ::print_array1;
using fastOutput ::print_array2;
using fastOutput ::print_chars_in_range;
using fastOutput ::print_string_in_range;
using fastOutput ::special_print_array1;
const int N = 1e5 + 7;
int n, a[N], sum, ans, ansp;
int main() {
  n = fastIO ::read<int>();
  for (int(i) = (1); (i) <= (n); ++(i))
    a[i] = fastIO ::read<int>(), sum += a[i], ansp = max(ansp + a[i], 0),
    ans = max(ans, ansp);
  return write(2 * ans - sum), 0;
}
