#include <bits/stdc++.h>
using namespace std;
long long n, A[1000001], dp[1000001];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> A[i];
  bool inc = true, dec = true;
  long long change;
  for (long long i = 2; i <= n; i++) {
    if (A[i] == A[i - 1])
      inc = dec = true, change = i - 1;
    else if (A[i] > A[i - 1] && dec)
      inc = true, dec = false, change = i - 1;
    else if (A[i] < A[i - 1] && inc)
      inc = false, dec = true, change = i - 1;
    dp[i] = max(dp[change] + llabs(A[i] - A[change + 1]),
                dp[change - 1] + llabs(A[i] - A[change]));
  }
  cout << dp[n];
  return 0;
}
