#include <bits/stdc++.h>
using namespace std;
const int MAX = 105000;
int data[MAX];
long long maxx[MAX];
int pre[MAX];
int nex[MAX];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &data[i]);
    if (i >= 2) {
      maxx[i - 1] = abs(data[i] - data[i - 1]);
    }
  }
  stack<int> stk;
  for (int i = 1; i < n; i++) {
    while (!stk.empty() && maxx[i] >= maxx[stk.top()]) {
      int now = stk.top();
      nex[now] = i;
      stk.pop();
    }
    if (stk.empty())
      pre[i] = 1;
    else {
      pre[i] = stk.top() + 1;
    }
    stk.push(i);
  }
  while (!stk.empty()) {
    int now = stk.top();
    nex[now] = n;
    stk.pop();
  }
  int ta, tb;
  long long ans = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &ta, &tb);
    ans = 0;
    for (int i = ta; i < tb; i++) {
      ans += (long long)(i - max(ta, pre[i]) + 1) * (min(tb, nex[i]) - i) *
             maxx[i];
    }
    cout << ans << endl;
  }
}
