#include <bits/stdc++.h>
using namespace std;
long long n, a[1001000], dp[1001000];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  dp[2] = abs(a[2] - a[1]);
  for (int i = 3; i <= n; i++) {
    if (a[i] >= a[i - 1] != a[i - 1] >= a[i - 2])
      dp[i] = max(dp[i - 1], dp[i - 2] + abs(a[i] - a[i - 1]));
    else
      dp[i] = abs(a[i] - a[i - 1]) + dp[i - 1];
  }
  printf("%lld", dp[n]);
  return 0;
}
