#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
void solve() {
  int n, q;
  cin >> n >> q;
  vector<int> A(n), B(n), L(n), R(n);
  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) {
    int x = B[i];
    while (!v.empty() && x > v.back().first) v.pop_back();
    L[i] = (v.size() > 0 ? v.back().second + 1 : 1);
    v.push_back(make_pair(x, i));
  }
  v.clear();
  for (int i = n - 1; i > 0; --i) {
    int x = B[i];
    while (!v.empty() && x >= v.back().first) v.pop_back();
    R[i] = v.size() > 0 ? v.back().second - 1 : n - 1;
    v.push_back(make_pair(x, i));
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    long long s = 0;
    for (int i = l + 1; i <= r; ++i) {
      int a = i - max(l + 1, L[i]) + 1;
      int b = min(r, R[i]) - i + 1;
      s += 1ll * a * b * B[i];
    }
    cout << s << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
