#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int arr[n + 1];
  arr[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long int prefix[n + 1];
  int prev = -1;
  memset(prefix, 0, sizeof(prefix));
  for (int i = 2; i <= n; i++) {
    if (prev == -1) prev = 1;
    prefix[i] = max(abs(arr[i] - arr[prev]) + prefix[prev - 1], prefix[i]);
    prefix[i] = max(abs(arr[i] - arr[prev + 1]) + prefix[prev], prefix[i]);
    if (i - 1 >= 1 && i + 1 <= n &&
            (arr[i] <= arr[i - 1] && arr[i] <= arr[i + 1]) ||
        arr[i] >= arr[i - 1] && arr[i] >= arr[i + 1])
      prev = i;
  }
  cout << prefix[n] << endl;
  return 0;
}
