#include <bits/stdc++.h>
using namespace std;
int n, q;
int first[100013];
stack<int> solve;
int a[100013];
int b[100013];
void query(int l, int r) {
  for (int i = l; i <= r; i++) a[i] = r + 1;
  for (int i = l; i <= r; i++) b[i] = l - 1;
  while (solve.size() > 0) solve.pop();
  for (int i = r; i >= l; i--) {
    while (solve.size() > 0 && first[i] >= first[solve.top()]) {
      b[solve.top()] = i;
      solve.pop();
    }
    solve.push(i);
  }
  while (solve.size() > 0) solve.pop();
  for (int i = l; i <= r; i++) {
    while (solve.size() > 0 && first[i] > first[solve.top()]) {
      a[solve.top()] = i;
      solve.pop();
    }
    solve.push(i);
  }
  long long ans = 0;
  for (int i = l; i <= r; i++) {
    ans += (long long)first[i] * (i - b[i]) * (a[i] - i);
  }
  printf("%lld\n", ans);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &first[i]);
  for (int i = 1; i < n; i++) first[i] = abs(first[i + 1] - first[i]);
  for (int Q = 0; Q < q; Q++) {
    int l, r;
    scanf("%d%d", &l, &r);
    r -= 1;
    query(l, r);
  }
  return 0;
}
