#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int b[N];
stack<int> s;
int l[N];
int r[N];
int main() {
  int n;
  scanf("%d", &n);
  ;
  int q;
  scanf("%d", &q);
  ;
  for (int i = 1; i < n + 1; i++) scanf("%d", &a[i]);
  ;
  for (int i = 1; i < n; i++) {
    b[i] = abs(a[i + 1] - a[i]);
  }
  s.push(0);
  b[0] = 1000000007;
  for (int i = 1; i < n; i++) {
    while (b[s.top()] <= b[i]) {
      s.pop();
    }
    l[i] = s.top() + 1;
    s.push(i);
  }
  while (!s.empty()) s.pop();
  s.push(n);
  b[n] = 1000000007;
  for (int i = n - 1; i >= 1; i--) {
    while (b[s.top()] < b[i]) {
      s.pop();
    }
    r[i] = s.top() - 1;
    s.push(i);
  }
  while (q--) {
    int x, y;
    scanf("%d", &x);
    ;
    scanf("%d", &y);
    ;
    long long ans = 0;
    for (int i = x; i < y; i++) {
      ans += 1LL * (i - max(l[i], x) + 1) * 1LL * (min(r[i], y - 1) - i + 1) *
             b[i];
    }
    printf("%lld\n", ans);
  }
  return 0;
}
