#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
long long a[N], l[N], r[N], s[N], top;
signed main() {
  long long n, q;
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    a[i - 1] = abs(a[i] - a[i - 1]);
  }
  a[0] = a[n] = 1e18;
  for (long long i = 1; i <= n; i++) {
    while (a[i] > a[s[top]]) r[s[top--]] = i;
    l[i] = s[top];
    s[++top] = i;
  }
  for (long long i = 1; i <= q; i++) {
    long long ans = 0;
    long long L, R;
    cin >> L >> R;
    for (long long i = L; i < R; i++) {
      ans += a[i] * (1 + i - max(l[i] + 1, L)) * (min(R, r[i]) - i);
    }
    cout << ans << "\n";
  }
}
