#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000100;
long long n, a[MAXN], memo[MAXN];
vector<long long> g[MAXN];
long long dfs(long long v) {
  if (v == n + 1) return 0;
  if (memo[v] != -1) return memo[v];
  long long ret = 0;
  for (auto u : g[v]) ret = max(ret, dfs(u + 1) + abs(a[u] - a[v]));
  return memo[v] = ret;
}
signed main() {
  memset(memo, -1, sizeof memo);
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  long long last = 1;
  for (long long i = 1; i < n; i++) {
    if (a[i - 1] <= a[i] && a[i] >= a[i + 1]) {
      g[last].push_back(i);
      if (last + 1 <= i) g[last + 1].push_back(i);
      if (last <= i - 1) g[last].push_back(i - 1);
      if (last + 1 <= i - 1) g[last + 1].push_back(i - 1);
      last = i;
    }
    if (a[i - 1] >= a[i] && a[i] <= a[i + 1]) {
      g[last].push_back(i);
      if (last + 1 <= i) g[last + 1].push_back(i);
      if (last <= i - 1) g[last].push_back(i - 1);
      if (last + 1 <= i - 1) g[last + 1].push_back(i - 1);
      last = i;
    }
  }
  g[last].push_back(n), g[last + 1].push_back(n);
  for (long long i = 1; i <= n; i++)
    sort(g[i].begin(), g[i].end()),
        g[i].erase(unique(g[i].begin(), g[i].end()), g[i].end());
  printf("%lld", dfs(1));
}
