#include <bits/stdc++.h>
using namespace std;
int a[100000];
int n;
int l[100000];
int r[100000];
void linearmin() {
  vector<int> v;
  v.clear();
  for (int i = 0; i < n; i++) {
    while (!v.empty() && a[v.back()] <= a[i]) v.pop_back();
    if (v.empty())
      l[i] = -1;
    else
      l[i] = v.back();
    v.push_back(i);
  }
  v.clear();
  for (int i = n - 1; i >= 0; i--) {
    while (!v.empty() && a[v.back()] < a[i]) v.pop_back();
    if (v.empty())
      r[i] = n;
    else
      r[i] = v.back();
    v.push_back(i);
  }
}
int q;
int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) a[i] = abs(a[i + 1] - a[i]);
  linearmin();
  while (q--) {
    int x, y;
    long long ans = 0;
    cin >> x >> y;
    x--, y--;
    for (int i = x; i < y; i++) {
      int e = min(r[i], y) - i;
      int f = 1 + i - max(x, l[i] + 1);
      ans += 1LL * e * f * a[i];
    }
    cout << ans << '\n';
  }
  return 0;
}
