#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 3;
int n, arr[Maxn], l[Maxn], r[Maxn], num[Maxn];
void findLR(int st, int en);
long long ANS(int st, int en);
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 1; i < n; ++i) num[i] = abs(arr[i] - arr[i - 1]);
  while (q--) {
    int st, en;
    cin >> st >> en;
    --st;
    st++;
    cout << ANS(st, en) << endl;
  }
  return 0;
}
void findLR(int st, int en) {
  memset(l, 0, sizeof l);
  memset(r, 0, sizeof r);
  stack<int> q;
  for (int i = st; i < en; ++i) {
    while (!q.empty() && num[i] >= num[q.top()]) {
      int x = q.top();
      q.pop();
      r[x] = i;
    }
    q.push(i);
  }
  while (!q.empty()) {
    r[q.top()] = en;
    q.pop();
  }
  for (int i = en - 1; i >= st; --i) {
    while (!q.empty() && num[i] > num[q.top()]) {
      int x = q.top();
      q.pop();
      l[x] = i + 1;
    }
    q.push(i);
  }
  while (!q.empty()) {
    l[q.top()] = st;
    q.pop();
  }
  return;
}
long long ANS(int st, int en) {
  findLR(st, en);
  long long ans = 0;
  for (int i = st; i < en; ++i)
    ans +=
        (long long)(i - l[i] + 1) * (long long)(r[i] - i) * (long long)num[i];
  return ans;
}
