#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int a[MAXN], b[MAXN], p[MAXN], f[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) b[i] = abs(a[i] - a[i - 1]);
  vector<pair<int, int> > v;
  for (int i = 1; i < n; i++) {
    while (v.size() and v.back().first <= b[i]) v.pop_back();
    if (v.empty())
      p[i] = 1;
    else
      p[i] = v.back().second + 1;
    v.push_back({b[i], i});
  }
  v.clear();
  for (int i = n - 1; i > 0; i--) {
    while (v.size() and v.back().first < b[i]) v.pop_back();
    if (v.empty())
      f[i] = n - 1;
    else
      f[i] = v.back().second - 1;
    v.push_back({b[i], i});
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    long long ans = 0;
    cin >> l >> r;
    l--;
    r--;
    for (int j = l + 1; j <= r; j++) {
      int s = max(l + 1, p[j]), e = min(r, f[j]);
      if (s > e) continue;
      long long x = j - s, y = e - j;
      ans += (x * y + x + y + 1ll) * b[j];
    }
    cout << ans << endl;
  }
  return 0;
}
