#include <bits/stdc++.h>
using namespace std;
const int SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
bool sgn(long long int a, long long int b) {
  if (a) a /= abs(a);
  if (b) b /= abs(b);
  return a * b == 1;
}
void test_case() {
  int n;
  cin >> n;
  vector<long long int> dp(n);
  vector<int> v(n);
  for (auto &x : v) cin >> x;
  for (int i = 1; i < n; i++) {
    dp[i] = max(dp[i - 1], (long long int)abs(v[i] - v[i - 1]));
    if (i > 1) {
      dp[i] = max(dp[i], dp[i - 2] + abs(v[i] - v[i - 1]));
      if (sgn(v[i] - v[i - 1], v[i - 1] - v[i - 2]))
        dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
    }
  }
  cout << dp[n - 1] << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    test_case();
  }
  return 0;
}
