#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 200;
int a[maxn];
long long dp[maxn][2];
int main() {
  int n;
  scanf("%d%d", &n, &a[1]);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > a[i - 1]) {
      dp[i][0] = max(dp[i - 1][1], dp[i - 1][0] + a[i] - a[i - 1]);
      dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]);
    } else {
      dp[i][1] = max(dp[i - 1][0], dp[i - 1][1] + a[i - 1] - a[i]);
      dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
    }
  }
  printf("%I64d\n", max(dp[n][0], dp[n][1]));
  return 0;
}
