#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
int mas[100500];
int mx[100500];
int rr[100500];
int ll[100500];
void solve() {
  int n = ri(), q = ri();
  for (int i = (int)(1); i <= (int)(n); i++) mas[i] = ri();
  for (int i = (int)(2); i <= (int)(n); i++) mx[i] = abs(mas[i] - mas[i - 1]);
  for (int i = (int)(1); i <= (int)(q); i++) {
    int l = ri(), r = ri();
    long long res = 0;
    rr[r] = r + 1;
    for (int j = (int)(r - 1); j >= (int)(l + 1); j--) {
      int p = j + 1;
      while (p <= r && mx[j] >= mx[p]) p = rr[p];
      rr[j] = p;
    }
    ll[l + 1] = l;
    for (int j = (int)(l + 2); j <= (int)(r); j++) {
      int p = j - 1;
      while (p > l && mx[j] > mx[p]) p = ll[p];
      ll[j] = p;
    }
    for (int j = (int)(l + 1); j <= (int)(r); j++) {
      long long tmp = mx[j];
      long long len = (long long)(rr[j] - j) * (long long)(j - ll[j]);
      res += tmp * len;
    }
    cout << res << endl;
  }
}
int main() {
  solve();
  return 0;
}
