func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5 + 100;   long long a[N];   int ansL[N], ansR[N];   int st[N];   long long diff[N];   long long solve(int x, int y) {     long long ans = 0;     int r = 0;     for (int i = x; i <= y - 1; i++) {       while (r > 0 && diff[st[r - 1]] < diff[i]) r--;       ansL[i] = (r == 0 ? x : st[r - 1] + 1);       st[r++] = i;     }     r = 0;     for (int i = y - 1; i >= x; i--) {       while (r > 0 && diff[st[r - 1]] <= diff[i]) r--;       ansR[i] = (r == 0 ? y : st[r - 1]);       st[r++] = i;     }     for (int i = x; i < y; i++) {       ans += 1LL * (i - ansL[i] + 1) * (ansR[i] - i) * diff[i];     }     return ans;   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     for (int i = 0; i < n; i++) scanf( %lld , &a[i]);     for (int i = 0; i < n - 1; i++) diff[i] = llabs(a[i + 1] - a[i]);     for (int i = 0; i < q; i++) {       int l, r;       scanf( %d%d , &l, &r);       printf( %lld n , solve(l - 1, r - 1));     }     return 0;   }   