func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, q, a[100010], l[100010], r[100010];   int st[100010], top;   int main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     n--;     for (int i = 1; i <= n; i++) a[i] = abs(a[i + 1] - a[i]);     for (int i = 1; i <= n; i++) {       while (top && a[st[top]] < a[i]) top--;       l[i] = st[top];       st[++top] = i;     }     top = 0;     st[top] = n + 1;     for (int i = n; i >= 1; i--) {       while (top && a[st[top]] <= a[i]) top--;       r[i] = st[top];       st[++top] = i;     }     for (int i = 1; i <= q; i++) {       int L, R;       long long ans = 0;       scanf( %d%d , &L, &R);       if (L >= R) {         puts( 0 );         continue;       }       R--;       for (int j = L; j <= R; j++) {         ans += (long long)(j - max(l[j], L - 1)) * (min(r[j], R + 1) - j) * a[j];       }       printf( %lld n , ans);     }     return 0;   }   