#include <bits/stdc++.h>
using namespace std;
int n, q, a[100005], sta[100005], top, llim[100005], rlim[100005], x, y;
long long ans;
int main() {
  scanf("%d%d", &n, &q);
  for (register int i = 1; i <= n; i++) scanf("%d", a + i);
  for (register int i = 1; i <= n - 1; i++)
    a[i] = abs(a[i + 1] - a[i]), llim[i] = 1, rlim[i] = n - 1;
  for (register int i = 1; i <= n - 1; i++) {
    while (top && a[sta[top]] <= a[i]) rlim[sta[top--]] = i - 1;
    sta[++top] = i;
  }
  top = 0;
  for (register int i = n - 1; i; i--) {
    while (top && a[sta[top]] < a[i]) llim[sta[top--]] = i + 1;
    sta[++top] = i;
  }
  for (register int i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    y--;
    ans = 0;
    for (register int j = x; j <= y; j++)
      ans += 1ll * a[j] * (j - max(llim[j], x) + 1) * (min(rlim[j], y) - j + 1);
    printf("%lld\n", ans);
  }
}
