#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int d[N], dp[N][20];
void pre(int n) {
  for (int i = 1; i <= n; i++) dp[i][0] = i;
  for (int i = 1; ((1 << i) - 1) < n; i++) {
    for (int j = 1; (j + (1 << i) - 1) <= n; j++) {
      dp[j][i] = dp[j][i - 1];
      if (d[dp[j][i - 1]] < d[dp[j + (1 << (i - 1))][i - 1]])
        dp[j][i] = dp[j + (1 << (i - 1))][i - 1];
    }
  }
}
int query(int l, int r) {
  int x = log2(r - l + 1);
  if (d[dp[l][x]] > d[dp[r - (1 << x) + 1][x]]) return dp[l][x];
  return dp[r - (1 << x) + 1][x];
}
long long solve(int l, int r) {
  if (l >= r) return 0;
  int ind = query(l, r - 1);
  long long ans = 1LL * (ind - l + 1) * (r - ind) * d[ind] + solve(l, ind) +
                  solve(ind + 1, r);
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q, l, r, n;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> d[i];
  for (int i = 2; i <= n; i++) d[i - 1] = abs(d[i] - d[i - 1]);
  pre(n - 1);
  while (q--) {
    cin >> l >> r;
    cout << solve(l, r) << "\n";
  }
  return 0;
}
