#include <bits/stdc++.h>
using namespace std;
int read() {
  int num = 0;
  bool flag = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') flag = 0;
  for (; c >= '0' && c <= '9'; c = getchar())
    num = (num << 1) + (num << 3) + c - '0';
  return flag ? num : -num;
}
const int N = 1e6 + 10;
int n, a[N];
long long f[N];
bool IF(int x) {
  if (a[x] > a[x - 1] && a[x - 1] > a[x - 2]) return 1;
  if (a[x] < a[x - 1] && a[x - 1] < a[x - 2]) return 1;
  return 0;
}
int main() {
  n = read();
  f[1] = 0;
  for (int i = 1; i <= n; i++) a[i] = read();
  f[2] = abs(a[1] - a[2]);
  for (int i = 3; i <= n; i++)
    if (IF(i))
      f[i] = f[i - 1] + abs(a[i] - a[i - 1]);
    else
      f[i] = max(f[i - 1], f[i - 2] + abs(a[i] - a[i - 1]));
  cout << f[n];
  return 0;
}
