#include <bits/stdc++.h>
using namespace std;
inline void maxm(int& a, int b) { a = a < b ? b : a; }
inline void minm(int& a, int b) { a = a < b ? a : b; }
int N;
int A[100000];
int dp[100000][3];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  dp[0][0] = -A[0];
  dp[0][1] = A[0];
  dp[0][2] = -A[0];
  dp[1][1] = A[1] - A[0];
  dp[1][2] = -A[0] - A[1];
  for (int i = 1; i < N; i++) {
    dp[i][0] = dp[i - 1][0] - A[i];
    dp[i][1] = dp[i - 1][0] + A[i];
    maxm(dp[i][1], dp[i - 1][1] + A[i]);
    dp[i][2] = dp[i][0];
    maxm(dp[i][2], dp[i - 1][1] - A[i]);
    maxm(dp[i][2], dp[i - 1][2] - A[i]);
  }
  cout << max(dp[N - 1][1], dp[N - 1][2]);
  return 0;
}
