#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000100;
void setmax(long long& a, long long b) {
  if (a < b) {
    a = b;
  }
}
int N;
int ar[MAXN];
int dir[MAXN];
long long DP[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> ar[i];
  }
  ar[0] = (long long)-(1E18);
  for (int i = 1; i <= N; ++i) {
    if (ar[i] > ar[i - 1]) {
      dir[i] = 0;
    } else {
      dir[i] = 1;
    }
  }
  for (int i = 0; i <= N; ++i) {
    DP[i] = 0;
  }
  int p = 0;
  for (int i = 1; i <= N; ++i) {
    if (dir[i] != dir[i - 1]) {
      p = i - 1;
    }
    if (p) setmax(DP[i], DP[p - 1] + abs(ar[i] - ar[p]));
    if (p < i) setmax(DP[i], DP[p] + abs(ar[i] - ar[p + 1]));
  }
  cout << DP[N] << endl;
  return 0;
}
