#include <bits/stdc++.h>
using namespace std;
const int maxm = 1e6 + 10;
const int maxn = 2e5 + 10;
int n, qq;
int a[maxn], l[maxn], r[maxn], q[maxn], pos[maxn];
int v[maxn];
int main() {
  while (~scanf("%d%d", &n, &qq)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i < n; i++) v[i] = abs(a[i + 1] - a[i]);
    q[0] = 1e9;
    pos[0] = 0;
    int pp = 0;
    for (int i = 1; i < n; i++) {
      while (q[pp] <= v[i]) pp--;
      l[i] = pos[pp];
      q[++pp] = v[i];
      pos[pp] = i;
    }
    q[0] = 1e9;
    pos[0] = n;
    pp = 0;
    for (int i = n - 1; i > 0; i--) {
      while (q[pp] < v[i]) pp--;
      r[i] = pos[pp];
      q[++pp] = v[i];
      pos[pp] = i;
    }
    while (qq--) {
      int ll, rr;
      scanf("%d%d", &ll, &rr);
      long long ans = 0;
      for (int i = ll; i < rr; i++) {
        long long tpv = 1;
        tpv = tpv * (i - max(l[i] + 1, ll) + 1) * (min(r[i], rr) - i) * v[i];
        ans += tpv;
      }
      printf("%I64d\n", ans);
    }
  }
}
