#include <bits/stdc++.h>
using namespace std;
int n, arr[100010], ans[100010][5];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  for (int i = 1; i <= n; ++i) {
    ans[i][1] = max(ans[i - 1][1], ans[i - 1][2]) + arr[i];
    ans[i][2] = ans[i - 1][2] - arr[i];
    ans[i][3] = max(ans[i - 1][1],
                    max(ans[i - 1][2], max(ans[i - 1][3], ans[i - 1][4]))) -
                arr[i];
  }
  ans[0][0] = max(ans[n][1], max(ans[n][2], max(ans[n][3], ans[n][4])));
  printf("%d", ans[0][0]);
  return 0;
}
