#include <bits/stdc++.h>
using namespace std;
int n, m, ta, tb, y[100005], z[100005];
long long x[100005], ans;
vector<int> la;
int main() {
  scanf("%d%d", &n, &m);
  for (int a = 0; a < n; a++) scanf("%I64d", &x[a]);
  n--;
  for (int a = 0; a < n; a++) x[a] = abs(x[a] - x[a + 1]);
  la.clear();
  for (int a = 0; a < n; a++) {
    while (!la.empty() && x[a] > x[la.back()]) {
      y[la.back()] = a - 1;
      la.pop_back();
    }
    la.push_back(a);
  }
  while (!la.empty()) {
    y[la.back()] = n - 1;
    la.pop_back();
  }
  for (int a = n - 1; a >= 0; a--) {
    while (!la.empty() && x[a] >= x[la.back()]) {
      z[la.back()] = a + 1;
      la.pop_back();
    }
    la.push_back(a);
  }
  while (!la.empty()) {
    z[la.back()] = 0;
    la.pop_back();
  }
  while (m--) {
    scanf("%d%d", &ta, &tb);
    ans = 0;
    ta--;
    tb -= 2;
    for (int a = ta; a <= tb; a++)
      ans +=
          x[a] * min(a - ta + 1, a - z[a] + 1) * min(tb - a + 1, y[a] - a + 1);
    printf("%I64d\n", ans);
  }
  return 0;
}
