#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)1E5 + 10;
int n, q, top;
int a[MAX], b[MAX];
long long f[MAX];
int st[MAX];
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 1; i < n; i++) b[i] = abs(a[i - 1] - a[i]);
  int l, r;
  for (int t = 0; t < q; t++) {
    scanf("%d%d", &l, &r);
    l--;
    r--;
    top = 0;
    long long res = 0;
    f[l] = 0;
    for (int i = l + 1; i <= r; i++) {
      while (top > 0 && b[st[top]] < b[i]) top--;
      int last;
      if (top == 0)
        last = l;
      else
        last = st[top];
      st[++top] = i;
      f[i] = f[last] + (long long)(i - last) * b[i];
      res += f[i];
    }
    printf("%I64d\n", res);
  }
}
