#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n;
  cin >> n;
  int l;
  long long ln = 0, lm = 0, lp = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (!i) l = x;
    long long a = max(max(ln, lm), lp);
    long long b = max(a, max(ln, lm) + l - x);
    long long c = max(a, max(ln, lp) - l + x);
    l = x, ln = a, lm = b, lp = c;
  }
  cout << max(ln, max(lm, lp)) << endl;
  return 0;
}
