#include <bits/stdc++.h>
using namespace std;
const int lim = 1e5 + 11;
int f[lim];
int s[lim];
int qq;
int x, y;
int ans;
int m, n;
int l[lim], r[lim];
int pos, old;
void add(int o, int l, int r) {
  if (l == r) {
    f[o] = old;
    return;
  }
  int mid = (l + r) / 2;
  if (pos <= mid)
    add(o << 1, l, mid);
  else
    add(o << 1 | 1, mid + 1, r);
  f[o] = max(f[o << 1], f[o << 1 | 1]);
}
void work() {
  unsigned long long ans = 0;
  for (int i = x + 1; i <= y; i++) {
    ans += ((unsigned long long)(i - l[i]) * (r[i] - i) * f[i]);
  }
  cout << ans << endl;
}
void fl(int now, int k) {
  if (k <= x || f[k] >= f[now]) {
    l[now] = k;
    return;
  }
  fl(now, l[k]);
}
void fr(int now, int k) {
  if (k > y || f[k] > f[now]) {
    r[now] = k;
    return;
  }
  fr(now, r[k]);
}
int main() {
  scanf("%d%d", &m, &qq);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &s[i]);
  }
  for (int i = 1; i <= qq; i++) {
    scanf("%d%d", &x, &y);
    n = 0;
    for (int i = x + 1; i <= y; i++) f[i] = abs(s[i] - s[i - 1]);
    l[x + 1] = x;
    for (int i = x + 2; i <= y; i++) {
      if (f[i] <= f[i - 1])
        l[i] = i - 1;
      else
        fl(i, l[i - 1]);
    }
    r[y] = y + 1;
    for (int i = y - 1; i > x; i--) {
      if (f[i] < f[i + 1])
        r[i] = i + 1;
      else
        fr(i, r[i + 1]);
    }
    work();
  }
  return 0;
}
