#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005, INF = 1e9;
int N, Q;
int a[MAX];
int h[MAX];
int l[MAX], r[MAX];
int main(void) {
  cin >> N >> Q;
  for (int i = (1), _b = (N); i <= _b; i++) cin >> a[i];
  for (int i = (2), _b = (N); i <= _b; i++) h[i] = abs(a[i] - a[i - 1]);
  h[1] = h[N + 1] = INF;
  for (int i = (2), _b = (N); i <= _b; i++) {
    l[i] = i;
    while (h[l[i] - 1] <= h[i]) l[i] = l[l[i] - 1];
  }
  for (int i = (N), _b = (2); i >= _b; i--) {
    r[i] = i;
    while (h[r[i] + 1] < h[i]) r[i] = r[r[i] + 1];
  }
  int L, R;
  long long res;
  for (int o = (1), _b = (Q); o <= _b; o++) {
    cin >> L >> R;
    ++L;
    res = 0;
    for (int i = (L), _b = (R); i <= _b; i++) {
      res += (1ll * (min(r[i], R) - i) * (i - max(l[i], L)) + min(r[i], R) -
              max(l[i], L) + 1) *
             h[i];
    }
    cout << res << "\n";
  }
  return 0;
}
