#include <bits/stdc++.h>
using namespace std;
int n, q;
int a[100005];
int first[100005][2];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i - 1] = abs(a[i - 1] - a[i]);
  }
  memset(first, -1, sizeof first);
  --n;
  first[n - 1][0] = n;
  a[n] = INT_MAX;
  for (int i = n - 2; i >= 0; --i) {
    int curr = i + 1;
    while (a[i] > a[curr]) curr = first[curr][0];
    first[i][0] = curr;
  }
  first[0][1] = -1;
  a[-1] = INT_MAX;
  for (int i = 1; i < n; ++i) {
    int curr = i - 1;
    while (a[i] >= a[curr]) curr = first[curr][1];
    first[i][1] = curr;
  }
  while (q--) {
    long long sm = 0;
    int l, r;
    cin >> l >> r;
    --l, r -= 2;
    long long ans = 0;
    for (int i = l; i <= r; ++i) {
      ans += 1LL * (i - max(first[i][1], l - 1)) *
             (min(r + 1, first[i][0]) - i) * a[i];
      sm += (i - max(first[i][1], l - 1)) * (min(r + 1, first[i][0]) - i);
    }
    cout << ans << '\n';
  }
  return 0;
}
