#include <bits/stdc++.h>
using namespace std;
const int N = 112345;
int n, Q, l, r;
int a[N], d[N];
int L[N], R[N];
int s[N], t;
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  s[t = 0] = 0;
  for (int i = 1; i < n; ++i) {
    d[i] = abs(a[i] - a[i - 1]);
    while (t && d[i] >= d[s[t]]) R[s[t--]] = i;
    L[i] = s[t], s[++t] = i;
  }
  while (t) R[s[t--]] = n;
  while (Q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    long long ans = 0;
    for (int i = l; i < r; ++i)
      ans += (long long)d[i] * (min(r, R[i]) - i) * (i - max(l - 1, L[i]));
    cout << ans << endl;
  }
  return 0;
}
