#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int arr[N + 100], Inc[N + 100], Dec[N + 100];
long long dp[N + 100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", arr + i);
  }
  Inc[1] = Dec[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (arr[i] > arr[i - 1]) {
      Inc[i] = Inc[i - 1];
    } else {
      Inc[i] = i;
    }
    if (arr[i] < arr[i - 1]) {
      Dec[i] = Dec[i - 1];
    } else {
      Dec[i] = i;
    }
    for (int j = 0; j <= 10 && Inc[i] + j <= i; j++) {
      dp[i] = max(dp[i], abs(arr[i] - arr[Inc[i] + j]) + dp[Inc[i] + j - 1]);
    }
    for (int j = 0; j <= 10 && Dec[i] + j <= i; j++) {
      dp[i] = max(dp[i], abs(arr[i] - arr[Dec[i] + j]) + dp[Dec[i] + j - 1]);
    }
  }
  printf("%lld\n", dp[n]);
}
