#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  size_t children_count;
  cin >> children_count;
  vector<long long int> communicativity(children_count);
  vector<int> mins(children_count), maxes(children_count),
      charismas(children_count);
  int charisma;
  cin >> charisma;
  mins[0] = maxes[0] = charismas[0] = charisma;
  for (int i = 1; i < children_count; ++i) {
    cin >> charisma;
    charismas[i] = charisma;
    if (maxes[i - 1] < charisma && maxes[i - 1] == charismas[i - 1]) {
      communicativity[i] = communicativity[i - 1] + (charisma - maxes[i - 1]);
      maxes[i] = charisma;
      mins[i] = mins[i - 1];
    } else if (mins[i - 1] > charisma && mins[i - 1] == charismas[i - 1]) {
      communicativity[i] = communicativity[i - 1] + (mins[i - 1] - charisma);
      mins[i] = charisma;
      maxes[i] = maxes[i - 1];
    } else {
      long long int two_point_case = 0;
      if (i >= 2) {
        two_point_case =
            communicativity[i - 2] + std::abs(charisma - charismas[i - 1]);
      }
      long long int one_point_case = communicativity[i - 1];
      if (two_point_case > one_point_case) {
        mins[i] = std::min(charisma, charismas[i - 1]);
        maxes[i] = std::max(charisma, charismas[i - 1]);
      } else {
        mins[i] = maxes[i] = charisma;
      }
      communicativity[i] = std::max(two_point_case, one_point_case);
    }
  }
  cout << communicativity[children_count - 1] << endl;
  return 0;
}
