#include <bits/stdc++.h>
const int maxn = 100005;
int n, N, q, a[maxn], stk[maxn];
long long d[maxn];
inline int read() {
  int res = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') res = res * 10 + ch - 48, ch = getchar();
  return res * f;
}
int main() {
  n = read();
  q = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  while (q--) {
    int l = read(), r = read();
    N = 0;
    for (int i = l + 1; i <= r; i++) d[++N] = abs(a[i] - a[i - 1]);
    long long now = 0, ans = 0;
    int top = 0;
    for (int i = 1; i <= N; i++) {
      while (top > 0 && d[stk[top]] <= d[i])
        now -= (stk[top] - stk[top - 1]) * d[stk[top]], top--;
      now += (i - stk[top]) * d[i];
      stk[++top] = i;
      ans += now;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
