#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const long long INF = (long long)1e18 + 7;
long long a[N], dp[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[2] = abs(a[2] - a[1]);
  int state = a[2] >= a[1] ? 1 : -1;
  int preid = 1;
  for (int i = 3; i <= n; i++) {
    int nstate = a[i] >= a[i - 1] ? 1 : -1;
    if (nstate != state) {
      state = nstate;
      preid = i - 1;
    }
    dp[i] = dp[i - 1];
    dp[i] = max(dp[i], dp[preid - 1] + abs(a[preid] - a[i]));
    dp[i] = max(dp[i], dp[preid] + abs(a[preid + 1] - a[i]));
  }
  cout << dp[n];
}
