#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000100;
long long dp[MAXN][2], n, a[MAXN];
long long f(int idx, int formIncreasing) {
  if (idx >= n - 1) {
    return 0;
  }
  if (dp[idx][formIncreasing] != -1) {
    return dp[idx][formIncreasing];
  }
  long long ans = 0;
  if (formIncreasing) {
    if (a[idx + 1] >= a[idx]) {
      ans = f(idx + 1, 1) + a[idx + 1] - a[idx];
    }
    ans = max(ans, f(idx + 1, 0));
    ans = max(ans, f(idx + 1, 1));
  } else {
    if (a[idx + 1] <= a[idx]) {
      ans = f(idx + 1, 0) + a[idx] - a[idx + 1];
    }
    ans = max(ans, f(idx + 1, 0));
    ans = max(ans, f(idx + 1, 1));
  }
  return dp[idx][formIncreasing] = ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof dp);
  cout << max(f(0, 0), f(0, 1)) << "\n";
}
