#include <bits/stdc++.h>
using namespace std;
int s[100005];
int righ[100005];
int lef[100005];
vector<pair<int, int> > v;
int main(void) {
  int n, q;
  ios_base ::sync_with_stdio(0);
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) cin >> s[i];
  for (int i = 1; i < n; ++i) v.push_back({abs(s[i] - s[i + 1]), i});
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  set<int> st;
  st.insert(n);
  st.insert(0);
  for (auto it : v) {
    auto nw = st.lower_bound(it.second);
    if (nw != st.begin() && *nw > it.second) --nw;
    lef[it.second] = *nw;
    while (nw != st.end() && *nw < it.second) ++nw;
    righ[it.second] = *nw;
    st.insert(it.second);
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    long long ans = 0;
    for (int i = l; i < r; ++i)
      ans += 1ll * abs(s[i] - s[i + 1]) * (i - max(l - 1, lef[i])) *
             (min(r, righ[i]) - i);
    cout << ans << '\n';
  }
  return 0;
}
