#include <bits/stdc++.h>
using namespace std;
void GetStr(char *res) {
  char c;
  for (;;) {
    c = getchar();
    if (c == ' ' || c == '\n')
      continue;
    else
      break;
  }
  *res = c;
  res++;
  for (;;) {
    c = getchar();
    if (c == ' ' || c == '\n' || c == EOF) break;
    *res = c;
    res++;
  }
  *res = '\0';
}
void Getll(long long &val) {
  char ch;
  bool bo = 0;
  val = 0;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch = '-') bo = 1;
  for (; '0' <= ch && ch <= '9';
       val = (val << 3) + (val << 1) + ch - '0', ch = getchar())
    ;
  if (bo) val = -val;
}
void Getint(int &val) {
  char ch;
  bool bo = 0;
  val = 0;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch = '-') bo = 1;
  for (; '0' <= ch && ch <= '9';
       val = (val << 3) + (val << 1) + ch - '0', ch = getchar())
    ;
  if (bo) val = -val;
}
int tc, n, arr[100001];
int dp[100001], sum, seb, ans;
int main() {
  Getint(n);
  for (int i = 0; i < n; i++) Getint(arr[i]);
  dp[0] = abs(arr[0]);
  sum = arr[0];
  for (int i = 1; i < n; i++) {
    sum += arr[i];
    dp[i] = max(dp[i - 1] + arr[i], abs(sum));
  }
  sum = seb = 0;
  ans = dp[n - 1];
  for (int i = n - 1; i > 0; i--) {
    sum += arr[i];
    seb = max(seb + arr[i], abs(sum));
    ans = max(ans, seb + dp[i - 1]);
  }
  seb = max(seb + arr[0], abs(sum + arr[0]));
  ans = max(ans, seb);
  printf("%d\n", ans);
  return 0;
}
