#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5, maxlgn = 17;
int n, a[maxn];
int delta[maxn];
int st[maxn][maxlgn];
int h[maxn];
int Max(int i, int j) { return delta[i] < delta[j] ? j : i; }
void InitSt(int n) {
  for (int i = 0; i < n; ++i) {
    st[i][0] = i;
  }
  for (int k = 1; 1 << k <= n; ++k) {
    for (int i = 0; i + (1 << k) <= n; ++i) {
      st[i][k] = Max(st[i][k - 1], st[i + (1 << k - 1)][k - 1]);
    }
  }
  h[0] = 0;
  for (int i = 1; i <= n; ++i) {
    h[i] = h[i - 1];
    while (1 << h[i] + 1 <= i) {
      ++h[i];
    }
  }
}
int Query(int l, int r) {
  int k = h[r - l];
  return Max(st[l][k], st[r - (1 << k)][k]);
}
long long Solve(int l, int r) {
  if (r - l <= 0) return 0;
  int mid = Query(l, r);
  long long ans = (long long)(mid - l + 1) * (r - mid) * delta[mid];
  ans += Solve(l, mid);
  ans += Solve(mid + 1, r);
  return ans;
}
int main(void) {
  int q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n - 1; ++i) {
    delta[i] = abs(a[i + 1] - a[i]);
  }
  InitSt(n - 1);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    --l;
    long long ans = Solve(l, r - 1);
    printf("%lld\n", ans);
  }
  return 0;
}
