#include <bits/stdc++.h>
using namespace std;
const int _ = 100005;
const int inf = 0x3f3f3f3f;
int a[_], l[_], r[_];
int sta[_], top;
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i), a[i - 1] = abs(a[i - 1] - a[i]);
    }
    a[0] = a[n] = inf;
    for (int i = 1; i <= n; i++) {
      while (a[i] > a[sta[top]]) r[sta[top--]] = i;
      l[i] = sta[top];
      sta[++top] = i;
    }
    while (m--) {
      int x, y;
      scanf("%d%d", &x, &y);
      long long ans = 0;
      for (int i = x; i < y; i++)
        ans +=
            (long long)a[i] * (min(y, r[i]) - i) * (1 + i - max(x, l[i] + 1));
      printf("%I64d\n", ans);
    }
  }
}
