#include <bits/stdc++.h>
using std::abs;
using std::cin;
using std::cout;
using std::endl;
using std::ios;
using std::max;
using std::min;
const int N = 1e5 + 5;
int n, q, a[N], last[N], next[N], qu[N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> q;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = n - 1; i; --i) a[i] = abs(a[i] - a[i - 1]);
  for (int i = 1, r = 0; i < n; ++i) {
    while (r && a[qu[r]] < a[i]) --r;
    qu[++r] = i;
    if (r == 1)
      last[i] = 0;
    else
      last[i] = qu[r - 1];
  }
  for (int i = n - 1, r = 0; i; --i) {
    while (r && a[qu[r]] <= a[i]) --r;
    qu[++r] = i;
    if (r == 1)
      next[i] = n;
    else
      next[i] = qu[r - 1];
  }
  for (int t = 1, l, r; t <= q; ++t) {
    long long ans = 0;
    cin >> l >> r, --l;
    for (int i = l + 1; i < r; ++i)
      ans += 1ll * (i - max(l, last[i])) * (min(r, next[i]) - i) * a[i];
    cout << ans << endl;
  }
}
