#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000001], ba, s[1000001], sa, L[1000001], R[1000001], qa, qb;
long long ans;
int main() {
  scanf("%d%d", &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, s[0] = n + 1;
  for (int i = n; i >= 1; i--) {
    while (sa != 0 && a[i] > a[s[sa]]) L[s[sa]] = i, --sa;
    R[i] = s[sa];
    ++sa, s[sa] = i;
  }
  while (sa) L[s[sa]] = 0, --sa;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &qa, &qb), qb--;
    ans = 0;
    for (int j = qa; j <= qb; j++)
      ans +=
          (long long)(a[j]) * (min(R[j], qb + 1) - j) * (j - max(L[j], qa - 1));
    printf("%lld\n", ans);
  }
  return 0;
}
