func_code_string: #include <bits/stdc++.h>   using namespace std;   int l[500000], r[500000];   long long a[500000];   int L, R;   int n, q;   int main() {     scanf( %d%d , &n, &q);     a[0] = 0;     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = n; i >= 1; i--) a[i] = abs(a[i] - a[i - 1]);     stack<int> S;     for (int i = 2; i <= n; i++) {       while (!S.empty() && a[i] >= a[S.top()]) {         r[S.top()] = i - 1;         S.pop();       }       if (!S.empty())         l[i] = S.top() + 1;       else         l[i] = 2;       S.push(i);     }     while (!S.empty()) {       r[S.top()] = n;       S.pop();     }     while (q--) {       scanf( %d%d , &L, &R);       L++;       long long ans = 0;       for (int i = L; i <= R; i++) {         ans += (long long)(i - max(L, l[i]) + 1) *                (long long)(min(R, r[i]) - i + 1) * a[i];       }       cout << ans << endl;     }     return 0;   }   