#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
long long arr[1000009], dp[1000009];
int main() {
  int a;
  cin >> a;
  for (int i = 1; i <= a; i++) scanf("%lld", arr + i);
  int in = 1, dc = 1;
  for (int i = 1; i <= a; i++) {
    if (arr[i] > arr[i - 1]) in = i;
    if (arr[i] < arr[i - 1]) dc = i;
    dp[i] = max(dp[dc - 1] + abs(arr[dc] - arr[i]),
                dp[in - 1] + abs(arr[in] - arr[i]));
    if (in != i) umax(dp[i], dp[in] + abs(arr[in + 1] - arr[i]));
    if (dc != i) umax(dp[i], dp[dc] + abs(arr[dc + 1] - arr[i]));
  }
  cout << dp[a] << endl;
  return 0;
}
