#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 6;
const long long INF = 1e15 + 6;
long long a[MAX_N];
long long b[MAX_N];
int main() {
  int n, q;
  while (scanf("%d %d", &n, &q) != EOF) {
    for (int i = 1; n >= i; i++) {
      scanf("%I64d", &b[i]);
      if (i > 1) a[i] = abs(b[i] - b[i - 1]);
    }
    while (q--) {
      int L, R;
      scanf("%d %d", &L, &R);
      L++;
      deque<pair<long long, long long> > dq;
      dq.push_back(make_pair(INF, L - 1));
      long long ans = 0;
      for (long long i = L; R + 1 >= i; i++) {
        long long add = a[i];
        if (i == R + 1) add = INF;
        while (dq.size() > 0 && add > dq[dq.size() - 1].first) {
          ans += ((i - dq[dq.size() - 1].second) *
                  (dq[dq.size() - 1].second - dq[dq.size() - 2].second)) *
                 (dq[dq.size() - 1].first);
          dq.pop_back();
        }
        dq.push_back(make_pair(add, i));
      }
      printf("%I64d\n", ans);
    }
  }
}
