#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 21;
int n;
long long w[MAXN];
long long a, b, c, car;
long long ff, ss, tt;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    if (!i) car = w[i];
    a = max(max(ff, ss), tt);
    b = max(max(ff, ss) + car - w[i], a);
    c = max(max(ff, tt) - car + w[i], a);
    ff = a;
    ss = b;
    tt = c;
    car = w[i];
  }
  cout << max(ss, max(ff, tt)) << '\n';
  return 0;
}
