func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   const int dir[8][2] = {{0, 1},  {1, 1},   {1, 0},  {1, -1},                          {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}};   const int dir8x[8] = {-1, -1, -1, 0, 0, 1, 1, 1};   const int dir8y[8] = {-1, 0, 1, 1, -1, -1, 0, 1};   const long long mod = 1e9 + 7;   const double PI = acos(-1.0);   long long po(long long a, long long b, long long mod) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) {       return b;     } else {       return gcd(b % a, a);     }   }   int n;   long long val[maxn], dp[maxn];   void solve() {     scanf( %d , &(n));     for (int i = 1; i <= n; i++) {       scanf( %lld , &val[i]);     }     int last = 1;     for (int i = 2; i <= n; i++) {       dp[i] = max(dp[last - 1] + labs(val[i] - val[last]),                   dp[last] + labs(val[i] - val[last + 1]));       if (val[i] <= val[i + 1] && val[i] <= val[i - 1]) {         last = i;       }       if (val[i] >= val[i + 1] && val[i] >= val[i - 1]) {         last = i;       }     }     long long res = dp[n];     printf( %lld , res);   }   int main() {     solve();     return 0;   }   