#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  char c;
  bool neg = false;
  while (!isdigit(c = getchar()) && c != '-')
    ;
  x = 0;
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  do {
    x = x * 10 + c - '0';
  } while (isdigit(c = getchar()));
  if (neg) x = -x;
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    write(-x);
    return;
  }
  if (x < 10) {
    putchar(char(x + 48));
  } else {
    write(x / 10);
    putchar(char(48 + x % 10));
  }
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
using namespace std;
int n;
long long dp[2][1001000], a[1001000];
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  if (n == 1) {
    writeln(0);
    return 0;
  }
  dp[0][2] = dp[1][2] = abs(a[2] - a[1]);
  for (int i = 3; i <= n; i++) {
    dp[0][i] = max(dp[0][i - 1], dp[1][i - 1]);
    dp[1][i] = max(dp[0][i - 2], dp[1][i - 2]) + abs(a[i - 1] - a[i]);
    if ((a[i - 2] - a[i - 1]) * (a[i - 1] - a[i]) > 0) {
      dp[1][i] = max(dp[1][i], dp[1][i - 1] + abs(a[i - 1] - a[i]));
    }
  }
  writeln(max(dp[0][n], dp[1][n]));
}
