#include <bits/stdc++.h>
using namespace std;
long long t1, n, i, r, x, y, le[200001], ri[200001], a[200001], b[200001],
    q[200001], ans;
int main() {
  scanf("%lld%lld", &n, &t1);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i < n; i++) b[i] = abs(a[i + 1] - a[i]);
  for (i = 1; i < n; i++) {
    while (r && b[i] > b[q[r]]) r--;
    le[i] = q[r];
    q[++r] = i;
  }
  r = 0;
  q[0] = n;
  for (i = n - 1; i; i--) {
    while (r && b[i] >= b[q[r]]) r--;
    ri[i] = q[r];
    q[++r] = i;
  }
  while (t1--) {
    scanf("%lld%lld", &x, &y);
    ans = 0;
    for (i = x; i < y; i++) {
      ans += (i - max(le[i], x - 1)) * (min(ri[i] - 1, y - 1) - i + 1) * b[i];
    }
    printf("%lld\n", ans);
  }
}
