#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int INF = 1 << 30;
int lh[maxn], rh[maxn], s[maxn], d[maxn];
int main() {
  int n, q;
  while (~scanf("%d%d", &n, &q)) {
    int x;
    scanf("%d", &x);
    for (int i = 1; i < n; ++i) {
      int y;
      scanf("%d", &y);
      d[i] = abs(y - x);
      x = y;
    }
    d[0] = d[n] = INF;
    int cnt = 0;
    s[cnt++] = 0;
    for (int i = 1; i < n; ++i) {
      while (d[s[cnt - 1]] <= d[i]) {
        --cnt;
      }
      lh[i] = i - s[cnt - 1];
      s[cnt++] = i;
    }
    cnt = 0;
    s[cnt++] = n;
    for (int i = n - 1; i; --i) {
      while (d[s[cnt - 1]] < d[i]) {
        --cnt;
      }
      rh[i] = s[cnt - 1] - i;
      s[cnt++] = i;
    }
    while (q--) {
      int l, r;
      long long ans = 0;
      scanf("%d%d", &l, &r);
      for (int i = l; i < r; ++i) {
        ans += 1LL * d[i] * min(rh[i], r - i) * min(lh[i], i - l + 1);
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
