#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int inp[100100];
void solve(int a[], int n) {
  stack<std::pair<int, int> > st;
  long long ans = 0;
  st.push(make_pair(a[0], 0));
  int pres = a[n];
  a[n] = MOD;
  for (int i = 1; i <= n; ++i) {
    if (st.empty() || st.top().first >= a[i]) {
      st.push(make_pair(a[i], i));
      continue;
    }
    std::pair<int, int> p = st.top();
    st.pop();
    int l = 0;
    if (!st.empty()) l = st.top().second + 1;
    ans += (p.second - l + 1) * 1LL * (i - p.second) * 1LL * p.first;
    i -= 1;
  }
  a[n] = pres;
  printf("%lld\n", ans);
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < (n); ++i) scanf("%d", inp + i);
  for (int i = n - 1; i > 0; --i) {
    inp[i] = abs(inp[i] - inp[i - 1]);
  }
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    --l, --r;
    solve(inp + l + 1, r - l);
  }
  return 0;
}
