#include <bits/stdc++.h>
using namespace std;
int Gcd(int a, int b) {
  if (b == 0) return a;
  return Gcd(b, a % b);
}
int Lcm(int a, int b) { return a / Gcd(a, b) * b; }
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 1e6 + 10;
int a[maxn], b[maxn];
int L[maxn], R[maxn];
int stk[maxn], top = -1;
int main() {
  int n = read(), q = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  while (q--) {
    int l = read(), r = read();
    int len = r - l;
    for (int i = l; i < r; i++) {
      b[i - l + 1] = abs(a[i + 1] - a[i]);
    }
    top = -1;
    for (int i = 1; i <= len; i++) {
      while (top != -1 && b[stk[top]] <= b[i]) top--;
      L[i] = top == -1 ? 0 : stk[top];
      stk[++top] = i;
    }
    top = -1;
    for (int i = len; i >= 1; i--) {
      while (top != -1 && b[stk[top]] < b[i]) top--;
      R[i] = top == -1 ? len + 1 : stk[top];
      stk[++top] = i;
    }
    long long ans = 0;
    for (int i = 1; i <= len; i++) {
      ans += 1ll * (i - L[i]) * (R[i] - i) * b[i];
    }
    printf("%lld\n", ans);
  }
  return 0;
}
