#include <bits/stdc++.h>
using namespace std;
long long pwr(long long a, long long b, long long mod) {
  if (b == 0) return 1;
  long long temp = pwr(a, b / 2, mod);
  temp = (temp * temp) % mod;
  if (b & 1) temp = (temp * a) % mod;
  return temp;
}
long long pwr(long long a, long long b) {
  if (b == 0) return 1;
  long long temp = pwr(a, b / 2);
  temp = (temp * temp);
  if (b & 1) temp = (temp * a);
  return temp;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long modularInverse(long long a, long long m) { return pwr(a, m - 2, m); }
long long a[1000007];
int prevPeak[1000007];
long long DP[1000007];
long long dp(int n) {
  if (n <= 0) {
    return 0;
  }
  if (DP[n] != -1) return DP[n];
  long long o1 = abs(a[n] - a[prevPeak[n]]) + dp(prevPeak[n] - 1);
  long long o2 = abs(a[n] - a[prevPeak[n] + 1]) + dp(prevPeak[n]);
  return DP[n] = max(o1, o2);
}
bool isOptima(int n) {
  if (a[n] >= a[n - 1] && a[n] >= a[n + 1]) return true;
  if (a[n] <= a[n - 1] && a[n] <= a[n + 1]) return true;
  return false;
}
int main() {
  int n;
  cin >> n;
  memset(DP, -1, sizeof(DP));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int lastOptima = 0;
  for (int i = 1; i < n; ++i) {
    prevPeak[i] = lastOptima;
    if (isOptima(i)) {
      lastOptima = i;
    }
  }
  cout << dp(n - 1);
}
