#include <bits/stdc++.h>
using namespace std;
int diff[100001], arr[100001];
int toLeft[100001], toRight[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n - 1; i++) {
    diff[i] = (abs(arr[i] - arr[i + 1]));
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    r;
    stack<pair<int, int> > stk;
    for (int i = (r)-1; i >= l; i--) {
      toLeft[i] = l;
      while (!stk.empty() && stk.top().first <= diff[i]) {
        toLeft[stk.top().second] = i + 1;
        stk.pop();
      }
      stk.push(make_pair(diff[i], i));
    }
    while (!stk.empty()) {
      stk.pop();
    }
    for (int i = l; i < r; i++) {
      toRight[i] = r - 1;
      while (!stk.empty() && stk.top().first < diff[i]) {
        toRight[stk.top().second] = i - 1;
        stk.pop();
      }
      stk.push(make_pair(diff[i], i));
    }
    long long int ans = 0;
    for (int i = l; i < r; i++) {
      long long int left = i - toLeft[i] + 1;
      long long int right = toRight[i] - i + 1;
      ans += left * right * diff[i];
    }
    cout << ans << endl;
  }
  return 0;
}
