#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, m;
int a[MAXN];
int L[MAXN], R[MAXN];
void work() {
  L[1] = 1;
  for (int i = 2; i <= n; i++) {
    int j = i - 1;
    while (j != 1 && a[j] <= a[i]) j = L[j];
    L[i] = j;
  }
  R[n] = n;
  for (int i = n - 1; i >= 1; i--) {
    int j = i + 1;
    while (j != n && a[j] < a[i]) j = R[j];
    R[i] = j;
  }
  for (int i = 1; i <= n; i++) {
    while (a[L[i]] > a[i] && L[i] < i) L[i]++;
    while (a[R[i]] >= a[i] && R[i] > i) R[i]--;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) a[i] = abs(a[i + 1] - a[i]);
  n--;
  work();
  while (m--) {
    int l, r;
    scanf("%d%d", &l, &r);
    long long ans = 0;
    r--;
    for (int i = l; i <= r; i++) {
      ans += (long long)(min(R[i], r) - i + 1) * (i - max(L[i], l) + 1) * a[i];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
