#include <bits/stdc++.h>
const int M = 1000005;
int val[M];
long long dp[M];
inline long long Max(long long a, long long b) { return a > b ? a : b; }
inline int Abs(int a) { return a > 0 ? a : -a; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  dp[1] = 0;
  if (n == 1) {
    puts("0");
    return 0;
  }
  dp[2] = Abs(val[1] - val[2]);
  for (int i = 3; i <= n; i++) {
    if (val[i] >= val[i - 1] && val[i - 1] >= val[i - 2])
      dp[i] = dp[i - 1] - val[i - 1] + val[i];
    else if (val[i] <= val[i - 1] && val[i - 1] <= val[i - 2])
      dp[i] = dp[i - 1] + val[i - 1] - val[i];
    else {
      dp[i] = Max(dp[i - 1], dp[i - 2] + Abs(val[i - 1] - val[i]));
    }
  }
  printf("%I64d\n", dp[n]);
  return 0;
}
