#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int a[N], b[N], st[N], l[N], r[N];
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  b[1] = 0;
  for (int i = 2; i <= n; i++) b[i] = abs(a[i] - a[i - 1]);
  int top = 0;
  for (int i = 1; i <= n; i++) {
    while (top != 0 && b[st[top - 1]] <= b[i]) top--;
    if (top == 0)
      l[i] = 1;
    else
      l[i] = st[top - 1] + 1;
    st[top++] = i;
  }
  top = 0;
  for (int i = n; i >= 1; i--) {
    while (top != 0 && b[st[top - 1]] < b[i]) top--;
    if (top == 0)
      r[i] = n;
    else
      r[i] = st[top - 1] - 1;
    st[top++] = i;
  }
  while (m--) {
    scanf("%d%d", &x, &y);
    long long ans = 0;
    for (int i = x + 1; i <= y; i++) {
      int L = max(x + 1, l[i]), R = min(r[i], y);
      ans += 1ll * b[i] * (i - L + 1) * (R - i + 1);
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
