#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];
  long long mx = A[n - 1];
  long long mn = -A[n - 1];
  long long x;
  for (int i = n - 1; i >= 0; i--) {
    x = max(mx - A[i], mn + A[i]);
    if (i >= 0) {
      mx = max(mx, x + A[i - 1]);
      mn = max(mn, x - A[i - 1]);
    }
  }
  cout << x << '\n';
  return 0;
}
