#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int a[maxn];
long long dp[maxn];
int main() {
  int n, x;
  while (cin >> n) {
    long long down, up;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    up = a[0], down = -a[0];
    for (int i = 0; i < n; i++) {
      dp[i + 1] = max(up - a[i], down + a[i]);
      if (i + 1 < n) {
        up = max(up, dp[i + 1] + a[i + 1]);
        down = max(down, dp[i + 1] - a[i + 1]);
      }
    }
    cout << dp[n] << endl;
  }
  return 0;
}
