#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = (int)5e4 + 10;
const int MOD = (int)1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  set<ll, greater<ll> > maxes{A[n - 1]};
  set<ll, greater<ll> > mins{-A[n - 1]};
  vector<long long> dp(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    long long x = *maxes.begin();
    long long y = *mins.begin();
    dp[i] = max(x - A[i], A[i] + y);
    if (i >= 0) {
      maxes.insert(dp[i] + A[i - 1]);
      mins.insert(dp[i] - A[i - 1]);
    }
  }
  cout << dp[0] << '\n';
  return 0;
}
