#include <bits/stdc++.h>
using namespace std;
long long arr[100010], acu_i[100010], min_i[100010], acu_d[100010];
int n;
int main() {
  memset(arr, 0, sizeof arr);
  memset(acu_i, 0, sizeof acu_i);
  memset(min_i, 0, sizeof min_i);
  memset(acu_d, 0, sizeof acu_d);
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> arr[i];
  acu_i[n + 1] = 0;
  min_i[n + 1] = 0;
  for (int i = n; i >= 1; i--) acu_i[i] = acu_i[i + 1] + arr[i];
  for (int i = n; i >= 1; i--) min_i[i] = min(acu_i[i], min_i[i + 1]);
  acu_d[0] = 0;
  for (int i = 1; i < n + 1; i++) acu_d[i] = acu_d[i - 1] + arr[i];
  for (int i = 1; i < n + 1; i++) acu_d[i] = acu_d[i] * -1LL;
  long long res = -10000000000LL;
  for (int i = 0; i < n + 1; i++) {
    res = max(res, acu_d[i] + acu_i[i + 1] - min_i[i + 1] * 2LL);
  }
  cout << res << endl;
}
