#include <bits/stdc++.h>
using namespace std;
int a1[100005], q[100005], l[100005], r[100005];
int n, m, x, lx, lq;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &x), a1[i] = abs(x - lx), lx = x;
  for (int i = 2; i <= n; i++) {
    while (lq && a1[q[lq]] <= a1[i]) r[q[lq--]] = i - 1;
    l[i] = q[lq];
    q[++lq] = i;
  }
  while (lq) r[q[lq--]] = n;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &lx);
    long long ans = 0;
    for (int i = x + 1; i <= lx; i++)
      ans += 1ll * a1[i] * (i - max(x, l[i])) * (min(lx, r[i]) - i + 1);
    printf("%lld\n", ans);
  }
}
