#include <bits/stdc++.h>
using namespace std;
long long int dp[1123456];
vector<int> v;
int a[1123456];
int main() {
  int n, i, j;
  long long int ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  a[n] = a[n - 1];
  for (i = 0; i < n - 1; i++) {
    j = i;
    v.clear();
    while (j + 1 < n) {
      v.push_back(abs(a[j + 1] - a[j]));
      if (a[j] >= a[j + 1] && a[j + 1] >= a[j + 2]) {
        break;
      }
      if (a[j] <= a[j + 1] && a[j + 1] <= a[j + 2]) {
        break;
      }
      j++;
    }
    dp[v.size()] = 0;
    dp[v.size() + 1] = 0;
    for (i = v.size() - 1; i >= 0; i--) {
      dp[i] = max(dp[i + 1], dp[i + 2] + v[i]);
    }
    ans += dp[0];
    i = j;
  }
  cout << ans << endl;
  return 0;
}
