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