#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050;
int a[maxn];
int sum;
int ans2, ans;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum += a[i], ans2 = max(ans2 + a[i], 0), ans = max(ans, ans2);
  }
  cout << 2 * ans - sum << endl;
  return 0;
}
