#include <bits/stdc++.h>
using namespace std;
const double EPS = -1e8;
const double Pi = acos(-1);
bool inline equ(double a, double b) { return fabs(a - b) < EPS; }
const int MAXN = 1000010;
int n;
long long in[MAXN];
long long dp[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> in[i];
  long long prvub = -20000000000000000ll, prvlb = -20000000000000000ll;
  for (int i = (1); i <= (n); i++) {
    dp[i] = dp[i - 1];
    prvub = max(prvub, in[i] + dp[i - 1]);
    prvlb = max(prvlb, -in[i] + dp[i - 1]);
    dp[i] = max(dp[i], max(prvub - in[i], prvlb + in[i]));
  }
  cout << dp[n] << '\n';
}
