func_code_string: #include <bits/stdc++.h>   using namespace std;   const double eps = 1E-9;   const double Exp = 2.718281828459045;   const double Pi = 3.1415926535897932;   const int Max_Bit = 63;   const int INF = 2000000000;   const long long LINF = 1000000000000000007ll;   const int MOD = 1000000007;   const int NMAX = 100005;   const int MMAX = 505;   const int KMAX = 6;   const string CODE =  CODEFORCES ;   const int go[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};   int n, a[NMAX], l[NMAX], r[NMAX];   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int main() {     int q, u, v;     scanf( %d%d , &n, &q);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i + 1]);     }     for (int i = 0; i < n - 1; ++i) {       a[i + 1] = abs(a[i + 2] - a[i + 1]);     }     a[0] = INF;     a[n] = INF;     for (int i = 1; i < n; ++i) {       l[i] = i - 1;       while (a[i] >= a[l[i]]) {         l[i] = l[l[i]];       }     }     for (int i = n - 1; i > 0; i--) {       r[i] = i + 1;       while (a[i] > a[r[i]]) {         r[i] = r[r[i]];       }     }     for (int i = 0; i < q; ++i) {       long long ans = 0;       scanf( %d%d , &u, &v);       for (int j = u; j < v; ++j) {         ans += (j - max(l[j], u - 1)) * 1ll * (min(r[j], v) - j) * 1ll * a[j];       }       printf( %I64d n , ans);     }     return 0;   }   