#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int a[MAXN] = {0};
long long b[MAXN] = {0}, Left[MAXN] = {0}, Right[MAXN] = {0};
int main() {
  int n, q, l, r;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 2; i <= n; i++) {
    b[i] = abs(a[i] - a[i - 1]);
  }
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    l++;
    for (int i = l; i <= r; i++) {
      Left[i] = i;
      while (Left[i] > l && b[i] > b[Left[i] - 1]) Left[i] = Left[Left[i] - 1];
    }
    for (int i = r; i >= l; i--) {
      Right[i] = i;
      while (Right[i] < r && b[i] >= b[Right[i] + 1])
        Right[i] = Right[Right[i] + 1];
    }
    long long ans = 0;
    for (int i = l; i <= r; i++)
      ans +=
          (long long)(Right[i] - i + 1) * (long long)(i - Left[i] + 1) * b[i];
    cout << ans << endl;
  }
}
