#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
long long n, Q, ans, l, r;
long long dis[N], L[N], R[N];
vector<long long> mx;
int main() {
  cin >> n >> Q;
  int u, v;
  for (int i = 0; i < n; i++) {
    cin >> v;
    if (i) dis[i] = abs(v - u);
    u = v;
  }
  while (Q--) {
    cin >> l >> r;
    mx.clear();
    for (int i = l; i <= r - 1; i++) {
      while (!mx.empty() && dis[mx.back()] < dis[i]) mx.pop_back();
      if (mx.empty())
        L[i] = l - 1;
      else
        L[i] = mx.back();
      mx.push_back(i);
    }
    mx.clear();
    for (int i = r - 1; i >= l; i--) {
      while (!mx.empty() && dis[mx.back()] <= dis[i]) mx.pop_back();
      if (mx.empty())
        R[i] = r;
      else
        R[i] = mx.back();
      mx.push_back(i);
    }
    ans = 0;
    for (int i = l; i <= r - 1; i++) ans += dis[i] * (R[i] - i) * (i - L[i]);
    cout << ans << endl;
  }
}
