#include <bits/stdc++.h>
using namespace std;
int n, q, a[111111], b[111111], s[111111], top, L[111111], R[111111], l, r, len;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  while (q--) {
    scanf("%d%d", &l, &r);
    len = r - l;
    for (int i = l; i < r; i++) b[i - l + 1] = abs(a[i] - a[i + 1]);
    top = 0;
    for (int i = 1; i <= len; i++) {
      while (top && b[i] >= b[s[top]]) top--;
      L[i] = top == 0 ? 0 : s[top];
      s[++top] = i;
    }
    top = 0;
    for (int i = len; i >= 1; i--) {
      while (top && b[i] > b[s[top]]) top--;
      R[i] = top == 0 ? len + 1 : s[top];
      s[++top] = i;
    }
    long long ans = 0;
    for (int i = 1; i <= len; i++) ans += 1ll * (i - L[i]) * (R[i] - i) * b[i];
    printf("%I64d\n", ans);
  }
  return 0;
}
