#include <bits/stdc++.h>
const int MAXN = 1000017;
using namespace std;
int a[MAXN];
long long f[2][MAXN];
void mainp() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  f[1][0] = 0ll;
  f[0][0] = 0ll;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] < a[i]) {
      f[1][i] = max(f[1][i - 1] + a[i] - a[i - 1], f[0][i - 1]);
      f[0][i] = max(f[1][i - 1], f[0][i - 1]);
    } else {
      f[1][i] = max(f[1][i - 1], f[0][i - 1]);
      f[0][i] = max(f[0][i - 1] + a[i - 1] - a[i], f[1][i - 1]);
    }
  }
  cout << max(f[1][n - 1], f[0][n - 1]) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  mainp();
  return 0;
}
