#include <bits/stdc++.h>
using namespace std;
long long calc(int *a, int n) {
  long long ret = 0, suml = 0;
  stack<pair<int, int> > st;
  for (int i = 2; i <= n; i++) {
    int l = 1;
    while (!st.empty() && abs(a[i] - a[i - 1]) > st.top().first) {
      suml -= st.top().first * (long long)st.top().second;
      l += st.top().second;
      st.pop();
    }
    st.push(make_pair(abs(a[i] - a[i - 1]), l));
    suml += abs(a[i] - a[i - 1]) * (long long)l;
    ret += suml;
  }
  return ret;
}
int n, m, a[100010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    printf("%I64d\n", calc(a + l - 1, r - l + 1));
  }
  return 0;
}
