#include <bits/stdc++.h>
using namespace std;
int n, q;
int a[100020];
int L[100020];
int R[100020];
int val[100020];
int pos[100020];
void Compute() {
  int st = 0;
  for (int i = 2; i <= n; i++) {
    int x = abs(a[i] - a[i - 1]);
    while (st && x >= val[st - 1]) st--;
    if (st == 0)
      L[i] = 0;
    else
      L[i] = pos[st - 1];
    val[st] = x;
    pos[st++] = i;
  }
  st = 0;
  for (int i = n; i > 1; i--) {
    int x = abs(a[i] - a[i - 1]);
    while (st && x > val[st - 1]) st--;
    if (st == 0)
      R[i] = n;
    else
      R[i] = pos[st - 1] - 1;
    val[st] = x;
    pos[st++] = i;
  }
}
int main() {
  int l, r;
  int q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  Compute();
  while (q--) {
    scanf("%d%d", &l, &r);
    long long ans = 0;
    for (int i = l + 1; i <= r; i++) {
      long long x = abs(a[i] - a[i - 1]);
      ans += x * (i - max(l, L[i])) * (min(r, R[i]) - i + 1);
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
