#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[114004], b[114004];
long long u, v;
long long l[114004], r[114004];
stack<long long> LS, RS;
long long __abs(long long x) { return x < 0 ? -x : x; }
int main() {
  scanf("%I64d%I64d", &n, &m);
  for (long long i = 0; i < n; i++) scanf("%I64d", &a[i]);
  for (long long i = 0; i < n - 1; i++) b[i] = __abs(a[i] - a[i + 1]);
  n--;
  for (long long i = 0; i < n; i++) {
    while (!LS.empty())
      if (b[LS.top()] <= b[i])
        LS.pop();
      else
        break;
    if (LS.empty())
      l[i] = 0;
    else
      l[i] = LS.top() + 1;
    LS.push(i);
  }
  for (long long i = n - 1; i >= 0; i--) {
    while (!RS.empty())
      if (b[RS.top()] < b[i])
        RS.pop();
      else
        break;
    if (RS.empty())
      r[i] = n - 1;
    else
      r[i] = RS.top() - 1;
    RS.push(i);
  }
  for (long long i = 0; i < m; i++) {
    scanf("%I64d%I64d", &u, &v);
    u -= 1, v -= 2;
    long long ans = 0;
    for (long long j = u; j <= v; j++) {
      ans += (b[j] * (min(v, r[j]) - j + 1) * (j + 1 - max(l[j], u)));
    }
    cout << ans << endl;
  }
  return 0;
}
