#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e7 + 13;
long long n, dp[maxN], a[maxN];
vector<long long> vec;
int32_t main() {
  cin >> n;
  vec.push_back(0);
  vec.push_back(0);
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 2; i < n; i++) {
    if (a[i] < a[i - 1] && a[i] <= a[i + 1]) {
      vec.push_back(i - 1);
      vec.push_back(i);
    } else if (a[i] <= a[i - 1] && a[i] < a[i + 1]) {
      vec.push_back(i - 1);
      vec.push_back(i);
    } else if (a[i] > a[i - 1] && a[i] >= a[i + 1]) {
      vec.push_back(i - 1);
      vec.push_back(i);
    } else if (a[i] >= a[i - 1] && a[i] > a[i + 1]) {
      vec.push_back(i - 1);
      vec.push_back(i);
    }
  }
  dp[0] = dp[1] = 0;
  for (long long i = 2; i < vec.size(); i += 2) {
    dp[i] = max(
        ((vec[i] != vec[i - 1]) ? dp[i - 1] + abs(a[vec[i]] - a[vec[i - 1] + 1])
                                : dp[i - 1]),
        dp[i - 2] + abs(a[vec[i]] - a[vec[i - 2] + 1]));
    dp[i + 1] = max(dp[i - 1] + abs(a[vec[i + 1]] - a[vec[i - 1] + 1]),
                    dp[i - 2] + abs(a[vec[i + 1]] - a[vec[i - 2] + 1]));
  }
  long long lst = vec.size() - 1;
  dp[n] = max(dp[lst] + abs(a[n] - a[vec[lst] + 1]),
              dp[lst - 1] + abs(a[n] - a[vec[lst - 1] + 1]));
  cout << dp[n] << endl;
}
