#include <bits/stdc++.h>
using namespace std;
long long int pre[100005], arr[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  pre[0] = arr[0];
  for (int i = 1; i < n; ++i) pre[i] = pre[i - 1] + arr[i];
  long long int sum = 0, mx = -1e10;
  for (int i = 0; i < n; ++i) {
    sum += arr[i];
    if (sum < 0) sum = 0;
    mx = max(mx, sum);
  }
  cout << max(pre[n - 1], 2 * mx - pre[n - 1]) << endl;
  return 0;
}
