#include <bits/stdc++.h>
using namespace std;
int n, q;
int arr[123456];
int prW[123556];
int leNM[123456];
int main() {
  cin >> n >> q;
  n--;
  int a, b;
  cin >> a;
  for (int i = 1; i <= (n); ++i) {
    cin >> b;
    arr[i] = abs(a - b);
    a = b;
  }
  vector<pair<int, int> > stack;
  for (int i = 1; i <= (n); ++i) {
    pair<int, int> elt = make_pair(arr[i], -i);
    while (!stack.empty() && elt > stack.back()) {
      prW[-stack.back().second] = i;
      stack.pop_back();
    }
    stack.push_back(elt);
  }
  while (!stack.empty()) {
    prW[-stack.back().second] = n + 1;
    stack.pop_back();
  }
  stack.clear();
  for (int i = n; i >= (1); --i) {
    pair<int, int> elt = make_pair(arr[i], -i);
    while (!stack.empty() && elt > stack.back()) {
      leNM[-stack.back().second] = i;
      stack.pop_back();
    }
    stack.push_back(elt);
  }
  while (!stack.empty()) {
    leNM[-stack.back().second] = 0;
    stack.pop_back();
  }
  int l, r;
  long long ans, cur;
  long long modl, modp;
  for (int x = 0; x < (q); ++x) {
    cin >> l >> r;
    --r;
    ans = 0;
    for (int i = l; i <= (r); ++i) {
      cur = arr[i];
      if (leNM[i] < l)
        modl = i - l + 1;
      else
        modl = i - leNM[i];
      if (prW[i] > r)
        modp = r - i + 1;
      else
        modp = prW[i] - i;
      cur *= modl;
      cur *= modp;
      ans += cur;
    }
    cout << ans << endl;
  }
}
