#include <bits/stdc++.h>
using namespace std;
const int N = 100009;
const int oo = (int)(1e8) + 10;
int n, query, a[N], b[N];
long long l[N], r[N];
int L, R;
stack<int> Stack;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> query;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= query; i++) {
    cin >> L >> R;
    int nn = 0;
    for (int i = L + 1; i <= R; i++) b[++nn] = abs(a[i] - a[i - 1]);
    while (!Stack.empty()) Stack.pop();
    b[0] = oo;
    Stack.push(0);
    for (int i = 1; i <= nn; i++) {
      while (!Stack.empty() && b[Stack.top()] <= b[i]) Stack.pop();
      l[i] = Stack.top();
      Stack.push(i);
    }
    while (!Stack.empty()) Stack.pop();
    b[nn + 1] = oo;
    Stack.push(nn + 1);
    for (int i = nn; i >= 1; i--) {
      while (!Stack.empty() && b[Stack.top()] < b[i]) Stack.pop();
      r[i] = Stack.top();
      Stack.push(i);
    }
    long long ans = 0;
    for (int i = 1; i <= nn; i++) {
      long long kk = (i - l[i]) * (r[i] - i);
      ans += b[i] * kk;
    }
    cout << ans << endl;
  }
}
