#include <bits/stdc++.h>
using namespace std;
struct node {
  int num, delta;
};
stack<node> Q;
int N, qus;
int data[100005] = {0};
long long int sum, ans;
void Q_Push(int num, int delta) {
  while (Q.top().delta <= delta) {
    long long int a = Q.top().delta, b = Q.top().num;
    Q.pop();
    sum -= a * (b - Q.top().num);
  }
  long long int a = Q.top().num;
  Q.push((node){num, delta});
  sum += delta * (num - a);
}
int main() {
  scanf("%d %d", &N, &qus);
  for (int i = 1; i <= N; i++) scanf("%d", &data[i]);
  while (qus--) {
    sum = ans = 0;
    int L, R;
    scanf("%d %d", &L, &R);
    Q.push((node){L, 0x7fffffff});
    for (int i = L + 1; i <= R; i++) {
      Q_Push(i, abs(data[i] - data[i - 1]));
      ans += sum;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
