#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll N; cin >> N; vector A(N+1); for (int i=1; i<=N; i++) cin >> A[i]; vector dp(N+1, vector(2, -1e18)); dp[0][0] = 0; for (int i=1; i<=N; i++){ dp[i][1] = max(dp[i-1][0]-A[i], dp[i-1][1]); dp[i][0] = max(dp[i-1][1]+A[i], dp[i-1][0]); } cout << max(dp[N][1], dp[N][0]) << endl; return 0; }