#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
void bugp(const pair<T, V> &x) {
  if (0) cerr << '{' << x.first << ", " << x.second << '}' << endl;
}
template <typename T, typename U, typename V>
void bugpp(const pair<T, pair<U, V> > &x) {
  if (0)
    cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
         << "}}" << endl;
}
template <typename T>
bool maximize(T &x, const T &y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
template <typename T>
bool minimize(T &x, const T &y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
const int N = 100010;
int n, arr[N], f[N], g[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int neg = 0, pos = 0;
  for (int i = 1, _n = (n); i <= _n; ++i) {
    if (0) cerr << ("i") << " = " << (i) << endl;
    cin >> arr[i];
    if (arr[i] < 0)
      neg += arr[i];
    else
      pos += arr[i];
    f[i] = max(f[i - 1] + arr[i], abs(neg) - pos);
    if (0) cerr << ("f[i]") << " = " << (f[i]) << endl;
  }
  neg = pos = 0;
  int ans = f[n];
  for (int i = (n); i > 0; --i) {
    if (0) cerr << ("i") << " = " << (i) << endl;
    if (arr[i] < 0)
      neg += arr[i];
    else
      pos += arr[i];
    g[i] = max(g[i + 1] + arr[i], abs(neg) - pos);
    maximize(ans, g[i] + f[i - 1]);
    if (0) cerr << ("g[i]") << " = " << (g[i]) << endl;
    if (0) cerr << ("ans") << " = " << (ans) << endl;
  }
  cout << ans;
  return 0;
}
