#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
struct node {
  int idx, v;
};
int n, m, a[MAXN];
int dmc[MAXN];
node dm[MAXN][20];
void lucky() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
}
void prep() {
  node u, v;
  dmc[1] = 0;
  for (int i = 2; i <= n; i++)
    dmc[i] = dmc[i - 1] + ((1 << (dmc[i - 1] + 1)) < i);
  for (int i = 1; i < n; i++)
    dm[i][0].idx = i, dm[i][0].v = abs(a[i] - a[i + 1]);
  for (int i = 1; (1 << i) <= n; i++) {
    for (int j = n - (1 << i) + 1; j >= 1; j--) {
      u = dm[j][i - 1], v = dm[j + (1 << (i - 1))][i - 1];
      dm[j][i] = (u.v > v.v) ? u : v;
    }
  }
}
node qMax(int l, int r) {
  node u, v;
  u = dm[l][dmc[r - l + 1]];
  v = dm[r - (1 << dmc[r - l + 1]) + 1][dmc[r - l + 1]];
  return (u.v > v.v) ? u : v;
}
long long solve(int l, int r) {
  if (l > r) return 0;
  node t = qMax(l, r);
  long long l1 = r - l + 1, l2 = t.idx - l, l3 = r - t.idx;
  long long res = solve(l, t.idx - 1) + solve(t.idx + 1, r);
  return res + ((l1 * l1 + l1 - l2 * l2 - l2 - l3 * l3 - l3) >> 1) * t.v;
}
int main() {
  int l, r;
  lucky();
  prep();
  for (int R = 1; R <= m; R++) {
    cin >> l >> r;
    cout << solve(l, r - 1) << endl;
  }
  return 0;
}
