#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
struct Node {
  int pos, val;
  Node() {}
  Node(int pos, int val) : pos(pos), val(val) {}
} st[maxn];
struct Query {
  int l, r;
  bool operator<(const Query& tmp) const { return r < tmp.r; }
} query[maxn];
int n, q, top;
int a[maxn], l[maxn], r[maxn];
long long ans[maxn];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int main() {
  if (fopen("in.in", "r") != NULL) {
    freopen("in.in", "r", stdin);
    freopen("out.out", "w", stdout);
  }
  n = read(), q = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = n; i >= 1; i--) a[i] = abs(a[i] - a[i - 1]);
  for (int i = 2; i <= n; i++) {
    while (top && st[top].val <= a[i]) top--;
    if (top) l[i] = st[top].pos + 1;
    st[++top] = Node(i, a[i]);
  }
  top = 0;
  for (int i = n; i >= 2; i--) {
    while (top && st[top].val < a[i]) top--;
    if (top)
      r[i] = st[top].pos - 1;
    else
      r[i] = n;
    st[++top] = Node(i, a[i]);
  }
  for (int i = 1; i <= q; i++) query[i].l = read(), query[i].r = read();
  for (int i = 1; i <= q; i++) {
    top = 0;
    for (int pos = query[i].l + 1; pos <= query[i].r; pos++) {
      int left = max(query[i].l + 1, l[pos]), right = min(query[i].r, r[pos]);
      ans[i] += (long long)(right - pos + 1) * (pos - left + 1) * a[pos];
    }
  }
  for (int i = 1; i <= q; i++) printf("%I64d\n", ans[i]);
  return 0;
}
