#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
const long long INF = 1e18;
int N;
int A[MAXN + 10];
long long dp[MAXN + 10];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  long long sa = -INF, sb = -INF;
  for (int i = N - 1; i >= 0; i--) {
    sa = max(sa, -A[i] + dp[i + 1]);
    sb = max(sb, A[i] + dp[i + 1]);
    dp[i] = max(A[i] + sa, sb - A[i]);
  }
  printf("%lld\n", dp[0]);
}
