#include <bits/stdc++.h>
using namespace std;
const long long N = 1000005;
long long a[N], f[N], n, k;
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  k = 1;
  for (long long i = 2; i <= n; i++) {
    if ((a[i] >= a[i - 1] && a[i - 1] <= a[i - 2]) ||
        (a[i] <= a[i - 1] && a[i - 1] >= a[i - 2])) {
      k = i - 1;
    }
    f[i] = max(f[k] + abs(a[i] - a[k + 1]), f[k - 1] + abs(a[i] - a[k]));
  }
  cout << f[n] << endl;
}
