#include <bits/stdc++.h>
long long dp[1000005][3];
int n, x, a[1000005];
long long max(long long x, long long y) { return x > y ? x : y; }
int main() {
  scanf("%d", &n);
  scanf("%d", &x);
  dp[1][0] = x;
  dp[1][2] = -x;
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &x);
    for (int k = 0; k < 3; ++k) {
      dp[i][k] = dp[i - 1][k];
      if (k > 0) dp[i][k] = max(dp[i][k], dp[i - 1][k - 1] - x);
      if (k < 2) dp[i][k] = max(dp[i][k], dp[i - 1][k + 1] + x);
    }
  }
  printf("%lld", dp[n][1]);
}
