#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000005;
int n;
long long A[MAXN], dp[MAXN][2];
long long def(long long a, long long b) {
  if (a == b) return 0;
  return (a - b) / abs(a - b);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (i == 0) {
      dp[0][1] = max(dp[1][0], dp[1][1] + abs(A[0] - A[1]));
    }
    if (def(A[i - 1], A[i]) == def(A[i], A[i + 1]) ||
        def(A[i], A[i + 1]) == 0 || (def(A[i - 1], A[i]) == 0)) {
      dp[i][1] = max(dp[i + 1][0], dp[i + 1][1] + abs(A[i] - A[i + 1]));
    } else {
      dp[i][0] = max(dp[i + 1][0], dp[i + 1][1] + abs(A[i] - A[i + 1]));
      dp[i][1] = max(dp[i + 1][1], dp[i + 1][0]);
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
  return 0;
}
