#include <bits/stdc++.h>
using namespace std;
const long long N = 200010;
inline long long read() {
  long long s = 0, w = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch - '0'), ch = getchar();
  return s * w;
}
void print(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
long long n, K, a[N], f[N], ql[N], qr[N], sta[N], tp;
signed main() {
  n = read(), K = read();
  for (register long long i = 1; i <= n; i++)
    a[i] = read(), f[i] = abs(a[i] - a[i - 1]);
  for (register long long i = 2; i <= n; i++) {
    while (tp && f[sta[tp]] <= f[i]) qr[sta[tp--]] = i - 1;
    ql[i] = sta[tp];
    sta[++tp] = i;
  }
  while (tp) qr[sta[tp--]] = n;
  for (register long long i = 1; i <= K; i++) {
    long long L, R, res;
    res = 0;
    L = read(), R = read();
    for (register long long j = L + 1; j <= R; j++)
      res += f[j] * (j - max(L, ql[j])) * (min(R, qr[j]) - j + 1);
    printf("%lld\n", res);
  }
  return 0;
}
