#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<int> diffs;
  for (int i = 0; i < n - 1; i++) {
    diffs.push_back(abs(arr[i + 1] - arr[i]));
  }
  for (int quer = 0; quer < q; quer++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    long long ans = 0;
    int sz = r - l;
    vector<int> leftGreater(n);
    vector<int> rightGreater(n);
    stack<pair<int, int> > myStack;
    for (int i = l; i < r; i++) {
      while (!myStack.empty() && myStack.top().first < diffs[i]) {
        myStack.pop();
      }
      if (myStack.empty()) {
        leftGreater[i] = l - 1;
      } else {
        leftGreater[i] = myStack.top().second;
      }
      myStack.push({diffs[i], i});
    }
    while (!myStack.empty()) myStack.pop();
    for (int i = r - 1; i >= l; i--) {
      while (!myStack.empty() && myStack.top().first <= diffs[i]) {
        myStack.pop();
      }
      if (myStack.empty()) {
        rightGreater[i] = r;
      } else {
        rightGreater[i] = myStack.top().second;
      }
      myStack.push({diffs[i], i});
    }
    for (int i = l; i < r; i++) {
      ans += ((long long)rightGreater[i] - i) * (i - leftGreater[i]) * diffs[i];
    }
    cout << ans << "\n";
  }
}
