#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxn = 1000006;
inline int sgn(int x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
int n;
int a[mxn];
ll f[mxn];
void EXEC() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int p = 1;
  for (int i = 2; i <= n; ++i) {
    if (sgn(a[i] - a[i - 1]) != sgn(a[p + 1] - a[p])) p = i - 1;
    f[i] = max(f[p] + abs(a[p + 1] - a[i]), f[p - 1] + abs(a[p] - a[i]));
  }
  cout << f[n] << endl;
}
int main() {
  EXEC();
  return 0;
}
