#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
int n, m;
int main() {
  long long n;
  long long q;
  cin >> n >> q;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  vector<long long> d;
  d.push_back(0LL);
  for (long long i = 1; i < n; i++) {
    d.push_back(abs(a[i] - a[i - 1]));
  }
  vector<long long> left, right;
  right.assign(n + 10, 1);
  left.assign(n + 10, 1);
  vector<long long> st;
  for (long long i = 1; i < n; i++) {
    while (st.size() != 0 && d[st.back()] < d[i]) {
      st.pop_back();
    }
    if (st.size() == 0) {
      left[i] = i;
    } else {
      left[i] = i - st.back();
    }
    st.push_back(i);
  }
  st.clear();
  for (long long i = n - 1; i >= 1; i--) {
    while (st.size() != 0 && d[st.back()] <= d[i]) {
      st.pop_back();
    }
    if (st.size() == 0) {
      right[i] = n - i;
    } else {
      right[i] = st.back() - i;
    }
    st.push_back(i);
  }
  while (q--) {
    long long l, r;
    cin >> l >> r;
    r--;
    long long ans = 0;
    for (long long i = l; i <= r; i++) {
      ans +=
          min(i - l + 1, left[i]) * min(r - i + 1, right[i]) * max(d[i], 0LL);
    }
    cout << ans << endl;
  }
  return 0;
}
