#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int inf = 0x3f3f3f3f;
int a[N], h[N], n, q;
int st[N], top, L[N], R[N];
int abs(int x) { return x < 0 ? -x : x; }
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  while (q--) {
    int l, r, m;
    scanf("%d%d", &l, &r);
    r--;
    m = r - l + 1;
    for (int i = 1; i <= m; i++) {
      h[i] = abs(a[i + l] - a[i + l - 1]);
    }
    h[m + 1] = inf;
    top = 0;
    for (int i = 1; i <= m + 1; i++) {
      while (top && h[st[top]] < h[i]) R[st[top]] = i - st[top], top--;
      L[i] = i - st[top];
      st[++top] = i;
    }
    long long ans = 0;
    for (int i = 1; i <= m; i++) ans += 1ll * h[i] * L[i] * R[i];
    printf("%lld\n", ans);
  }
}
