#include <bits/stdc++.h>
using namespace std;
int n, q;
int A[100007] = {0}, L[100007] = {0}, R[100007] = {0};
stack<int> S;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  for (int i = n; i > 1; i--) {
    A[i] -= A[i - 1];
    if (A[i] < 0) A[i] = -A[i];
  }
  for (int i = 2; i <= n; i++) {
    while (S.size() && A[S.top()] < A[i]) S.pop();
    L[i] = S.size() ? (S.top() + 1) : 2;
    S.push(i);
  }
  while (S.size()) S.pop();
  for (int i = n; i >= 2; i--) {
    while (S.size() && A[S.top()] <= A[i]) S.pop();
    R[i] = S.size() ? (S.top() - 1) : n;
    S.push(i);
  }
  int l, r;
  for (int i = 0; i < q; i++) {
    long long ans = 0;
    scanf("%d%d", &l, &r);
    l++;
    for (int j = l; j <= r; j++) {
      int l0 = max(l, L[j]), r0 = min(r, R[j]);
      ans +=
          (long long)(j - l0 + 1) * (long long)(r0 - j + 1) * (long long)A[j];
    }
    cout << ans << endl;
  }
  return 0;
}
