#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int C = 26;
void add(int &x, int y) {
  x += y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
}
int fix(int x) {
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
int pw(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % MOD;
    b >>= 1;
    a = 1ll * a * a % MOD;
  }
  return ret;
}
const int MAXN = 1e5 + 10;
long long n, q, a[MAXN], b[MAXN];
int blue[MAXN], red[MAXN], vec[MAXN];
void go(int l, int r) {
  fill(blue + l, blue + r, l - 1);
  fill(red + l, red + r, r);
  int tt = 0;
  for (int i = l; i < r; i++) {
    while (tt && b[vec[tt - 1]] <= b[i]) --tt;
    if (tt) blue[i] = vec[tt - 1];
    vec[tt++] = i;
  }
  tt = 0;
  for (int i = r - 1; i >= l; --i) {
    while (tt && b[vec[tt - 1]] < b[i]) --tt;
    if (tt) red[i] = vec[tt - 1];
    vec[tt++] = i;
  }
  long long ans = 0;
  for (int i = l; i < r; i++) ans += b[i] * (red[i] - i) * (i - blue[i]);
  cout << ans << "\n";
}
void solve() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i + 1 < n; i++) b[i] = abs(a[i] - a[i + 1]);
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    go(l, r);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int te = 1;
  for (int w = 1; w <= te; w++) {
    solve();
  }
  return 0;
}
