#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const double PI = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  long long ar[n + 5];
  for (long long i = 1; i <= n; i++) {
    cin >> ar[i];
  }
  long long d[n + 5];
  for (long long i = 1; i < n; i++) {
    d[i] = abs(ar[i] - ar[i + 1]);
  }
  d[0] = 1e18;
  d[n] = 1e18;
  long long next_great[n + 5];
  long long prev_great[n + 5];
  for (long long i = 1; i < n; i++) {
    next_great[i] = i + 1;
    prev_great[i] = i - 1;
  }
  for (long long i = n - 1; i > 0; i--) {
    long long tmp = next_great[i];
    while (d[tmp] <= d[i]) {
      tmp = next_great[tmp];
    }
    next_great[i] = tmp;
  }
  for (long long i = 1; i < n; i++) {
    long long tmp = prev_great[i];
    while (d[tmp] < d[i]) {
      tmp = prev_great[tmp];
    }
    prev_great[i] = tmp;
  }
  while (q--) {
    long long l, r;
    cin >> l >> r;
    long long ans = 0;
    for (long long i = l; i < r; i++) {
      long long left = max(l - 1, prev_great[i]);
      long long right = min(r, next_great[i]);
      ans += d[i] * (i - left) * (right - i);
    }
    cout << ans << "\n";
  }
}
