#include <bits/stdc++.h>
const int INF = 1000 * 1000 * 1000;
using namespace std;
int p[100500];
int a[100500];
int b[100500];
int mx[100500];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  for (int i = 1; i <= n; ++i) {
    a[i] = a[i - 1] + (-p[i]);
    mx[i] = max(a[i], mx[i - 1] + p[i]);
  }
  for (int i = 1; i <= n; ++i) b[i] = a[n] - a[i - 1];
  int ans = -INF;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, mx[i] + b[i + 1]);
  }
  cout << ans << "\n";
  return 0;
}
