#include <bits/stdc++.h>
using namespace std;
long long solve(int b, int e, int n, const vector<long long> &d) {
  stack<int> l, r;
  vector<long long> width(n + 1);
  for (long long i = b; i <= e; i++) {
    while (!l.empty() && d[i] > d[l.top()]) l.pop();
    if (l.empty())
      width[i] = i - b + 1;
    else
      width[i] = i - l.top();
    l.push(i);
  }
  for (long long i = e; i >= b; i--) {
    while (!r.empty() && d[i] >= d[r.top()]) r.pop();
    if (r.empty())
      width[i] += (e - i) * width[i];
    else
      width[i] += (r.top() - i - 1) * width[i];
    r.push(i);
  }
  long long ans = 0;
  for (int i = b; i <= e; i++) ans += d[i] * width[i];
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<long long> a(n + 1), d(n);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) {
    d[i - 1] = abs(a[i] - a[i - 1]);
  }
  while (q--) {
    int b, e;
    cin >> b >> e;
    cout << solve(b, e - 1, n, d) << '\n';
  }
  return 0;
}
