#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, q;
  cin >> n >> q;
  long long a[n + 10], t[n + 10], l[n + 10], r[n + 10], L, R;
  cin >> a[0];
  for (long long i = 1; i < n; i++)
    cin >> a[i], t[i - 1] = abs(a[i] - a[i - 1]);
  l[0] = -1;
  for (long long i = 1; i <= n; i++) {
    long long ind = i - 1;
    while (ind > -1 && t[ind] < t[i]) ind = l[ind];
    l[i] = ind;
  }
  r[n - 1] = n;
  for (long long i = n - 2; i >= 0; i--) {
    long long ind = i + 1;
    while (ind < n && t[ind] <= t[i]) ind = r[ind];
    r[i] = ind;
  }
  for (long long i = 0; i < q; i++) {
    long long ans = 0;
    cin >> L >> R;
    L--;
    R--;
    for (long long j = L; j < R; j++) {
      ans += (j - max(l[j], L - 1)) * (min(r[j], R) - j) * t[j];
    }
    cout << ans << endl;
  }
  return 0;
}
