#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e6 + 10;
int a[SIZE];
int b[SIZE], L[SIZE];
int stk[SIZE], pos[SIZE];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &(a[i]));
    if (i) {
      b[i] = abs(a[i] - a[i - 1]);
    }
  }
  while (q--) {
    long long an = 0;
    int x, y;
    scanf("%d%d", &x, &y);
    int sn = 0;
    for (int i = (x); i < (y); ++i) {
      while (sn && b[i] >= b[stk[sn - 1]]) {
        sn--;
      }
      int lt = x - 1;
      if (sn) lt = stk[sn - 1];
      L[i] = (i - lt);
      stk[sn++] = i;
    }
    sn = 0;
    for (int i = y - 1; i >= x; i--) {
      while (sn && b[i] > b[stk[sn - 1]]) {
        sn--;
      }
      int lt = y;
      if (sn) lt = stk[sn - 1];
      an += (lt - i) * (long long)b[i] * L[i];
      stk[sn++] = i;
    }
    cout << an << endl;
  }
  return 0;
}
