#include <bits/stdc++.h>
const long long N = 1000006;
long long n;
long long a[N];
long long f[N];
void init() {
  std::cin >> n;
  for (long long i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    a[i] = t;
  }
}
void work() {
  long long best[2] = {-a[1], a[1]};
  for (long long i = 1; i <= n; i++) {
    f[i] = std::max(a[i] + best[0], best[1] - a[i]);
    best[0] = std::max(best[0], f[i] - a[i + 1]);
    best[1] = std::max(best[1], f[i] + a[i + 1]);
  }
  std::cout << f[n] << std::endl;
}
int main() {
  init();
  work();
  return 0;
}
