#include <bits/stdc++.h>
using namespace std;
int n, q, a[200005], diff[200005];
int lft[200005], rht[200005];
stack<int> ss;
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%d", &q);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i < n; i++) {
    diff[i] = abs(a[i] - a[i + 1]);
  }
  for (i = 1; i < n; i++) {
    while (ss.size() && diff[ss.top()] < diff[i]) ss.pop();
    if (ss.size() == 0)
      lft[i] = i - 1;
    else {
      int pos = ss.top();
      lft[i] = i - pos - 1;
    }
    ss.push(i);
  }
  while (ss.size()) ss.pop();
  for (i = n - 1; i >= 1; i--) {
    while (ss.size() && diff[ss.top()] <= diff[i]) ss.pop();
    if (ss.size() == 0)
      rht[i] = (n - 1) - i;
    else {
      int pos = ss.top();
      rht[i] = pos - i - 1;
    }
    ss.push(i);
  }
  while (q--) {
    int l, r;
    scanf("%d", &l);
    scanf("%d", &r);
    long long ans = 0;
    for (i = l; i < r; i++) {
      int mylft = min(lft[i], i - l);
      int myrht = min(rht[i], (r - 1) - i);
      ans += diff[i] * ((long long)mylft * myrht + mylft + myrht + 1);
    }
    printf("%lld\n", ans);
  }
}
