#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 1e6 + 10;
const int inf = 0x7fffffff;
const long long INF = 9E18;
const int mod = 1e9 + 7;
const long long mod2 = 1e9 + 9;
const int eps = 1e-7;
const double pi = acos(-1.0);
template <typename T>
inline void read(T &x) {
  T f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
long long dp[maxn], a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) read(a[i]);
  int las = 1;
  for (int i = 2; i <= n; i++) {
    dp[i] = max(dp[las] + labs(a[i] - a[las + 1]),
                dp[las - 1] + labs(a[i] - a[las]));
    if (i < n) {
      if (a[i - 1] <= a[i] && a[i] >= a[i + 1]) las = i;
      if (a[i - 1] >= a[i] && a[i] <= a[i + 1]) las = i;
    }
  }
  cout << dp[n] << endl;
  return 0;
}
