#include <bits/stdc++.h>
using namespace std;
int n, q, ar[100001];
inline long long solve(int L, int R) {
  long long ret = 0;
  stack<int> s;
  for (int i = L; i <= R; i++) {
    while (s.size() && ar[s.top()] <= ar[i]) {
      int m = s.top();
      s.pop();
      int l = (s.size()) ? (s.top() + 1) : L;
      ret += (long long)(m - l + 1) * (i - m) * ar[m];
    }
    s.push(i);
  }
  while (s.size()) {
    int m = s.top();
    s.pop();
    int l = (s.size()) ? (s.top() + 1) : L;
    ret += (long long)(m - l + 1) * (R - m + 1) * ar[m];
  }
  return ret;
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 0; i < n - 1; i++) {
    ar[i] = abs(ar[i] - ar[i + 1]);
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << solve(l - 1, r - 2) << "\n";
  }
  return 0;
}
