#include <bits/stdc++.h>
using namespace std;
long long a[100100], b[100100], lef[100100], rig[100100];
int main() {
  long long ans;
  int n, q, i, l, r;
  while (cin >> n >> q) {
    for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (i = 2; i <= n; i++) b[i] = abs(a[i] - a[i - 1]);
    while (q--) {
      scanf("%d%d", &l, &r);
      ans = 0;
      l++;
      for (i = l; i <= r; i++) {
        lef[i] = i;
        while (lef[i] > l && b[i] > b[lef[i] - 1]) lef[i] = lef[lef[i] - 1];
      }
      for (i = r; i >= l; i--) {
        rig[i] = i;
        while (rig[i] < r && b[i] >= b[rig[i] + 1]) rig[i] = rig[rig[i] + 1];
      }
      for (i = l; i <= r; i++) {
        ans += (i - lef[i] + 1) * (rig[i] - i + 1) * b[i];
      }
      cout << ans << endl;
    }
  }
}
