#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int a[N + 3], L[N + 3], R[N + 3], n, m;
long long ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) a[i] = abs(a[i] - a[i + 1]);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    --r;
    R[r] = r + 1;
    for (int j = r - 1; j >= l; j--) {
      int w = j + 1;
      for (; a[w] <= a[j] && w <= r; w = R[w])
        ;
      R[j] = w;
    }
    L[l] = l - 1;
    for (int j = l + 1; j <= r; j++) {
      int w = j - 1;
      for (; a[w] < a[j] && w >= l; w = L[w])
        ;
      L[j] = w;
    }
    ans = 0;
    for (int j = l; j <= r; j++) ans += 1ll * a[j] * (j - L[j]) * (R[j] - j);
    printf("%I64d\n", ans);
  }
}
