#include <bits/stdc++.h>
using namespace std;
int n, a[1000005];
long long f[1000005];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int j = 1;
  memset(f, 0, sizeof(f));
  f[2] = abs(a[1] - a[2]);
  for (int i = 3; i <= n; i++) {
    if ((a[i] >= a[i - 1] && a[i - 1] <= a[i - 2]) ||
        (a[i] <= a[i - 1] && a[i - 1] >= a[i - 2]))
      j = i - 1;
    f[i] = max(f[j - 1] + abs(a[i] - a[j]), f[j] + abs(a[i] - a[j + 1]));
  }
  long long kq = -1;
  for (int i = 1; i <= n; i++) kq = max(kq, f[i]);
  cout << kq;
}
