#include <bits/stdc++.h>
using namespace std;
long long labs(long long a) {
  if (a < 0) return -a;
  return a;
}
struct data {
  long long val;
  int ind;
  data() {}
  data(long long v, int ii) {
    val = v;
    ind = ii;
  }
};
int n, q;
long long a[200000];
int main(void) {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    l--;
    r--;
    long long res = 0, sum = 0;
    stack<data> sta;
    sta.push(data(3e8, l));
    for (int i = l; i < r; i++) {
      long long c = labs(a[i + 1] - a[i]);
      while (sta.top().val < c) {
        data d = sta.top();
        sta.pop();
        sum -= (long long)d.val * (d.ind - sta.top().ind);
      }
      sum += (long long)c * (i + 1 - sta.top().ind);
      sta.push(data(c, i + 1));
      res += sum;
    }
    cout << res << endl;
  }
  return 0;
}
