#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, z, cnt, sum, num, ans;
long long a[1000005], dp[1000005][2];
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!('0' <= c && c <= '9')) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (('0' <= c && c <= '9')) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  dp[2][1] = abs(a[2] - a[1]);
  for (int i = 3; i <= n; i++) {
    if (a[i - 1] <= a[i] && a[i - 1] <= a[i - 2] ||
        a[i - 1] >= a[i] && a[i - 1] >= a[i - 2]) {
      dp[i][1] = dp[i - 1][0] + abs(a[i] - a[i - 1]);
      dp[i][0] = max(dp[i - 1][1], dp[i - 1][0]);
    } else {
      dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + abs(a[i] - a[i - 1]);
      dp[i][0] = max(dp[i - 1][1], dp[i - 1][0]);
    }
  }
  cout << max(dp[n][1], dp[n][0]);
  return 0;
}
