#include <bits/stdc++.h>
template <class T>
T read(T &a) {
  a = 0;
  char x = getchar();
  bool f = 0;
  for (; x < '0' || x > '9'; x = getchar()) f |= x == '-';
  for (; x >= '0' && x <= '9'; x = getchar()) a = (a << 3) + (a << 1) + x - '0';
  if (f) a = -a;
  return a;
}
using namespace std;
const int N = 1e6 + 5;
long long f[N][2], d[N];
int n, ans;
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(d[i]);
  }
  for (int i = 2; i <= n; ++i) {
    if (d[i] == d[i - 1]) {
      f[i][1] = f[i][0] = max(f[i - 1][1], f[i - 1][0]);
      continue;
    }
    if (d[i] > d[i - 1]) {
      f[i][1] =
          max(f[i - 1][1] + d[i] - d[i - 1], f[i - 2][0] + d[i] - d[i - 1]);
      f[i][0] = f[i - 1][0];
    } else {
      f[i][0] =
          max(f[i - 1][0] + d[i - 1] - d[i], f[i - 2][1] + d[i - 1] - d[i]);
      f[i][1] = f[i - 1][1];
    }
  }
  printf("%lld\n", max(f[n][0], f[n][1]));
  return 0;
}
