#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int pre[1000005];
long long dp[1000005], a[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n) {
    for (int i = (1); i <= (n); i++) cin >> a[i];
    for (int i = (1); i <= (n); i++) {
      if (i == 1 || i == n || (a[i] - a[i - 1]) * (a[i] - a[i + 1]) > 0 ||
          (a[i] - a[i - 1] == 0 && a[i] - a[i + 1] != 0) ||
          (a[i] - a[i - 1] != 0 && a[i] - a[i + 1] == 0)) {
        if (v.size() == 0)
          pre[i] = 0;
        else
          pre[i] = *(v.end() - 1);
        v.push_back(i);
      }
    }
    memset(dp, 0, sizeof(dp));
    for (auto u : v) {
      dp[u] = max(dp[u], dp[pre[u]] + abs(a[u] - a[pre[u] + 1]));
      if (pre[u] != 0)
        dp[u] = max(dp[u], dp[pre[u] - 1] + abs(a[u] - a[pre[u]]));
      if (u - 1 > pre[u])
        dp[u - 1] = max(dp[u - 1], dp[pre[u]] + abs(a[u - 1] - a[pre[u] + 1]));
      if (pre[u] != 0 && u > pre[u])
        dp[u - 1] = max(dp[u - 1], dp[pre[u] - 1] + abs(a[u - 1] - a[pre[u]]));
    }
    cout << dp[n] << endl;
  }
  return 0;
}
