#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005], L[100005], R[100005];
int main() {
  int n, q, l, r;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) b[i] = abs(a[i] - a[i - 1]), L[i] = R[i] = i;
  b[1] = b[n + 1] = 1000000009;
  for (int i = 2; i <= n; i++)
    while (b[i] >= b[L[i] - 1]) L[i] = L[L[i] - 1];
  for (int i = n; i > 1; i--)
    while (b[i] > b[R[i] + 1]) R[i] = R[R[i] + 1];
  while (q--) {
    cin >> l >> r;
    long long ans = 0;
    if (r == l) {
      cout << "0\n";
      continue;
    }
    l++;
    for (int i = l; i <= r; i++)
      ans += 1LL * (i - max(l, L[i]) + 1) * (min(r, R[i]) - i + 1) * b[i];
    cout << ans << "\n";
  }
  return 0;
}
