#include <bits/stdc++.h>
using namespace std;
template <typename T>
using vc = vector<T>;
using pii = pair<long long, long long>;
void xmax(long long& a, long long b) { a = max(a, b); }
void xmin(long long& a, long long b) { a = min(a, b); }
void print(vc<long long>& a, string second) {
  cerr << second << " : ";
  for (long long i = 0; i < a.size(); i++) {
    cerr << a[i] << " ";
  }
  cerr << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vc<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vc<long long> down(n);
  vc<long long> up(n);
  for (long long i = 1; i < n; i++) {
    if (a[i] >= a[i - 1]) {
      up[i] = max(up[i - 1] + abs(a[i] - a[i - 1]), down[i - 1]);
      down[i] = max(down[i - 1], up[i - 1]);
    } else {
      down[i] = max(down[i - 1] + abs(a[i] - a[i - 1]), up[i - 1]);
      up[i] = max(up[i - 1], down[i - 1]);
    }
  }
  cout << max(down[n - 1], up[n - 1]) << "\n";
}
