#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int INF = 1e9 + 7;
int n, q;
int a[MAXN];
int d[MAXN];
int le[MAXN];
int ri[MAXN];
long long solve(int qa, int qb) {
  if (qa == qb) return 0;
  int ls, rs;
  long long ret = 0;
  qb--;
  for (int i = qa; i <= qb; i++) {
    ls = max(le[i], qa);
    rs = min(ri[i], qb);
    ret += (long long)(i - ls + 1) * (long long)(rs - i + 1) * d[i];
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n - 1; i++) d[i] = abs(a[i + 1] - a[i]);
  d[0] = d[n] = INF;
  for (int i = 0; i <= n; i++) le[i] = ri[i] = i;
  for (int i = 1; i < n; i++)
    while (d[le[i] - 1] <= d[i]) le[i] = le[le[i] - 1];
  for (int i = n - 1; i >= 1; i--)
    while (d[ri[i] + 1] < d[i]) ri[i] = ri[ri[i] + 1];
  int qa, qb;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &qa, &qb);
    printf("%lld\n", solve(qa, qb));
  }
  return 0;
}
