#include <bits/stdc++.h>
using namespace std;
template <typename C>
void maxi(C& a, C b) {
  if (a < b) a = b;
}
template <typename C>
void mini(C& a, C b) {
  if (a > b) a = b;
}
template <class TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char* sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
int n, q;
int t[100010];
void test() {
  int a, b;
  scanf("%d%d", &a, &b);
  ("test", a, b);
  a--;
  b--;
  long long war = 0;
  long long res = 0;
  vector<pair<int, int> > stos;
  for (int i = a; i < b; i++) {
    (t[i]);
    int sze = 1;
    while (((int)(stos).size()) > 0 && stos.back().first < t[i]) {
      war -= stos.back().first * 1ll * stos.back().second;
      sze += stos.back().second;
      stos.pop_back();
      ("tu");
    }
    (t[i], sze);
    stos.push_back({t[i], sze});
    war += t[i] * 1ll * sze;
    res += war;
  }
  printf("%lld\n", res);
}
int main() {
  scanf("%d%d", &n, &q);
  int ost;
  scanf("%d", &ost);
  for (int i = 0; i < n - 1; i++) {
    int pom;
    scanf("%d", &pom);
    t[i] = abs(pom - ost);
    ost = pom;
  }
  while (q--) test();
}
