#include <bits/stdc++.h>
using namespace std;
int a[1111111];
long long dp[1111111];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int pos = 1;
  for (int i = 2; i <= n; i++) {
    dp[i] = dp[pos - 1] + abs(a[i] - a[pos]);
    dp[i] = max(dp[i], dp[pos] + abs(a[i] - a[pos + 1]));
    if (a[i] >= a[i - 1] && a[i] >= a[i + 1]) pos = i;
    if (a[i] <= a[i - 1] && a[i] <= a[i + 1]) pos = i;
  }
  printf("%I64d\n", dp[n]);
  return 0;
}
