#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int n;
int a[N];
int up[N];
long long ans[N];
long long dis(int x, int y) { return max(a[x], a[y]) - min(a[x], a[y]); }
int same(int x, int y, int z) {
  if (a[x] < a[y] && a[y] < a[z]) return 1;
  if (a[x] > a[y] && a[y] > a[z]) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1]) {
      up[i] = i;
      ans[i] = ans[i - 1];
      continue;
    }
    if (same(up[i - 1], i - 1, i)) {
      up[i] = up[i - 1];
      if (up[i - 1] == 0) {
        ans[i] = dis(up[i], i);
      } else {
        ans[i] =
            max(dis(i, up[i]) + ans[up[i] - 1], ans[up[i]] + dis(up[i] + 1, i));
      }
    } else {
      up[i] = i - 1;
      ans[i] = ans[i - 1];
      if (i >= 2)
        ans[i] = max(ans[i], ans[i - 2] + dis(i - 1, i));
      else
        ans[i] = max(ans[i], dis(i - 1, i));
    }
  }
  printf("%I64d", ans[n - 1]);
  return 0;
}
