#include <bits/stdc++.h>
using namespace std;
long long dp[1000007];
int v[1000007];
int main() {
  int i, j, k, l, m, n;
  long long a, b;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d", v + i);
  }
  if (n == 1) {
    cout << 0;
    return 0;
  } else if (n == 2) {
    cout << max(0, abs(v[0] - v[1]));
    return 0;
  }
  int in = 1;
  int dc = 1;
  dp[0] = 0;
  dp[1] = 0;
  int prev;
  for (i = 1; i < n; i++) {
    if (v[i - 1] == v[i]) {
      in = 1;
      dc = 1;
      prev = i - 1;
    } else if (dc && v[i] > v[i - 1]) {
      in = 1;
      dc = 0;
      prev = i - 1;
    } else if (in && v[i] < v[i - 1]) {
      in = 0;
      dc = 1;
      prev = i - 1;
    }
    a = dp[prev + 1] + abs(v[i] - v[prev + 1]);
    b = dp[prev] + abs(v[i] - v[prev]);
    dp[i + 1] = max(a, b);
  }
  printf("%I64d\n", dp[n]);
  return 0;
}
