#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long dp[1000005];
int main() {
  long long i, j, k;
  long long n, l;
  scanf("%lld", &n);
  v.push_back(0);
  for (i = 0; i < n; i++) {
    scanf("%lld", &j);
    v.push_back(j);
  }
  if (v.size() == 2) {
    printf("0\n");
    return 0;
  }
  dp[0] = dp[1] = 0;
  l = 1;
  for (i = 2; i < v.size(); i++) {
    dp[i] = dp[i - 1];
    dp[i] = max(dp[i], dp[i - 2] + abs(v[i] - v[i - 1]));
    dp[i] = max(dp[i], dp[l - 1] + abs(v[i] - v[l]));
    dp[i] = max(dp[i], dp[l] + abs(v[i] - v[l + 1]));
    if ((v[i] - v[i - 1]) < 0 && (v[i + 1] - v[i]) >= 0) l = i;
    if ((v[i] - v[i - 1]) > 0 && (v[i + 1] - v[i]) <= 0) l = i;
  }
  printf("%lld\n", dp[v.size() - 1]);
  return 0;
}
