#include <bits/stdc++.h>
using namespace std;
int a[110000];
int dp[110000] = {0};
int main() {
  int sum = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int s = 0;
  for (int i = 1; i <= n; i++) {
    sum += a[i];
    dp[i] = a[i];
    if (dp[i - 1] > 0) dp[i] += dp[i - 1];
    s = max(s, dp[i]);
  }
  int ans = s - (sum - s);
  cout << ans << endl;
  return 0;
}
