#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
  if (a > b) {
    return a;
  }
  return b;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
long long int min(long long int a, long long int b) {
  if (a < b) {
    return a;
  }
  return b;
}
long long int power(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      res = (res * x) % 1000000007;
    }
    x = (x * x) % 1000000007;
    n = n / 2;
  }
  return res % 1000000007;
}
long long int factorialNumInverse[1000001];
long long int naturalNumInverse[1000001];
long long int fact[1000001];
void InverseofNumber(long long int n, long long int p) {
  naturalNumInverse[0] = naturalNumInverse[1] = 1;
  for (long long int i = 2; i <= n; i++)
    naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
void InverseofFactorial(long long int n, long long int p) {
  factorialNumInverse[0] = factorialNumInverse[1] = 1;
  for (long long int i = 2; i <= n; i++)
    factorialNumInverse[i] =
        (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}
void factorial(long long int n, long long int p) {
  fact[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % p;
  }
}
long long int nCrModp(long long int n, long long int r, long long int p) {
  long long int ans =
      ((fact[n] * factorialNumInverse[r]) % p * factorialNumInverse[n - r]) % p;
  return ans;
}
long long int solve(long long int x) {
  if ((x & 3) == 0) {
    return x;
  }
  if ((x & 3) == 1) {
    return 1;
  }
  if ((x & 3) == 2) {
    return x + 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  factorial(200005, 1000000007);
  InverseofNumber(200005, 1000000007);
  InverseofFactorial(200005, 1000000007);
  long long int n;
  cin >> n;
  long long int arr[n];
  long long int prefix[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long int sum1 = 0;
  long long int sum2 = 0;
  for (int i = 1; i <= n; i++) {
    sum1 += arr[i];
    sum2 -= arr[i];
    prefix[i] = max(sum1, sum2);
    if (i > 1) {
      prefix[i] = max(prefix[i], prefix[i - 1] + arr[i]);
    }
  }
  long long int suffix[n + 1];
  sum1 = 0;
  sum2 = 0;
  for (int i = n; i >= 1; i--) {
    sum1 += arr[i];
    sum2 -= arr[i];
    suffix[i] = max(sum1, sum2);
    if (i < n) {
      suffix[i] = max(suffix[i], suffix[i + 1] + arr[i]);
    }
  }
  long long int ans = LONG_MIN;
  ans = max(suffix[1], prefix[n]);
  for (int i = 1; i <= n - 1; i++) {
    ans = max(ans, prefix[i] + suffix[i + 1]);
  }
  cout << ans << "\n";
  return 0;
}
