#include <bits/stdc++.h>
using namespace std;
int n, q, h[100010], a[100010], l, r, top, st[100010], lp[100010], rp[100010];
long long ans;
int main() {
  scanf("%d%d", &n, &q);
  for (register int i = 1; i <= n; ++i) scanf("%d", &h[i]);
  while (q--) {
    scanf("%d%d", &l, &r), --r, ans = 0;
    int len = r - l + 1;
    for (register int i = 1; i <= len; ++i) a[i] = abs(h[l + i - 1] - h[l + i]);
    for (register int i = 1; i <= len; ++i) {
      while (top && a[st[top]] < a[i]) rp[st[top--]] = i - 1;
      lp[i] = st[top] + 1;
      st[++top] = i;
    }
    while (top) rp[st[top--]] = len;
    for (register int i = 1; i <= len; ++i)
      ans += 1ll * a[i] * (i - lp[i] + 1) * (rp[i] - i + 1);
    printf("%lld\n", ans);
  }
  return 0;
}
