#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int LIM = 1000010;
const int mod = (1e9 + 7);
int main() {
  cin.sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, s = 0, s1 = 0, p = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s += x;
    p = max(p + x, x);
    s1 = max(s1, p);
  }
  cout << 2 * s1 - s << endl;
}
