#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 100;
long long int bigL[maxN], bigR[maxN], L[maxN], a[maxN];
long long int n, q;
void input() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
int recBigL(int pos, int x) {
  if (x <= L[pos]) return pos;
  if (pos <= 1) return 0;
  return recBigL(bigL[pos], x);
}
int recBigR(int pos, int x) {
  if (x < L[pos]) return pos;
  if (pos >= n) return n;
  return recBigR(bigR[pos], x);
}
void alg(int l, int r) {
  for (int i = 2; i <= n; i++) bigL[i] = recBigL(i - 1, L[i]);
  for (int i = n - 1; i >= 0; i--) bigR[i] = recBigR(i + 1, L[i]);
}
int main() {
  input();
  for (int i = 1; i < n; i++) L[i] = fabs(a[i] - a[i + 1]);
  alg(1, n);
  for (int i = 1; i <= q; i++) {
    int l, r;
    cin >> l >> r;
    for (int i = l; i < r; i++) {
    }
    long long int ans = 0;
    for (int i = l; i < r; i++) {
      ans += L[i] * (i - max(bigL[i], (long long)(l - 1))) *
             (min(bigR[i], (long long)r) - i);
    }
    cout << ans << endl;
  }
  return 0;
}
