#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
int a[MAX], b[MAX], cnt[MAX], ans;
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i], b[i] = abs(a[i] - a[i - 1]);
  while (q--) {
    long long ans = 0;
    int l, r;
    cin >> l >> r, l++;
    vector<pair<int, int> > ll, rr;
    for (int i = l; i <= r; i++) {
      int tmp = 1;
      while (ll.size() && b[i] >= ll.back().first)
        tmp += ll.back().second, ll.pop_back();
      ll.push_back({b[i], tmp}), cnt[i] = tmp;
    }
    for (int i = r; i >= l; i--) {
      int tmp = 1;
      while (rr.size() && b[i] > rr.back().first)
        tmp += rr.back().second, rr.pop_back();
      rr.push_back({b[i], tmp}), ans += 1LL * cnt[i] * tmp * b[i];
    }
    cout << ans << '\n';
  }
}
