#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
int n, q;
int a[MAX_N], d[MAX_N];
int toLeft[MAX_N], toRight[MAX_N];
int main() {
  scanf("%d%d", &n, &q);
  for (int(i) = (0); (i) < (n); ++(i)) scanf("%d", a + i);
  for (int(i) = (0); (i) < (n - 1); ++(i)) d[i] = abs(a[i + 1] - a[i]);
  --n;
  stack<int> left;
  left.push(-1);
  for (int(i) = (0); (i) < (n); ++(i)) {
    while ((left).size() > 1 && d[left.top()] < d[i]) left.pop();
    toLeft[i] = left.top();
    left.push(i);
  }
  stack<int> right;
  right.push(n);
  for (int(i) = (n - 1); (i) > (-1); --(i)) {
    while ((right).size() > 1 && d[right.top()] <= d[i]) right.pop();
    toRight[i] = right.top();
    right.push(i);
  }
  int a, b, l, r;
  long long ans;
  while (q--) {
    scanf("%d%d", &a, &b);
    --a, --b;
    ans = 0LL;
    for (int(i) = (a); (i) < (b); ++(i)) {
      l = max(a - 1, toLeft[i]);
      r = min(b, toRight[i]);
      ans += (long long)(i - l) * (r - i) * d[i];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
