#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 1e5 + 10;
long long a[N];
int L[N];
int R[N];
int main() {
  int n;
  int q;
  scanf("%d", &n);
  scanf("%d", &q);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = n - 1; i > 0; i--) a[i] = abs(a[i] - a[i - 1]);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    r--;
    vector<tuple<long long, int, long long>> vp;
    long long ans = 0;
    for (int i = l; i <= r; i++) {
      while (!vp.empty() && get<0>(vp.back()) < a[i]) vp.pop_back();
      long long res = 0;
      if (vp.empty())
        res = (i - l + 1) * a[i];
      else
        res = (i - get<1>(vp.back())) * a[i] + get<2>(vp.back());
      vp.push_back({a[i], i, res});
      ans += res;
    }
    cout << ans << endl;
  }
  return 0;
}
