#include <bits/stdc++.h>
using namespace std;
struct Pll {
  long long first, second;
  bool operator<(const Pll &r) const {
    return first > r.first || first == r.first && second < r.second;
  }
};
int ids[100001], count2, st;
long long a[100001], dif[100001];
Pll ord[100001], tree[100001 * 3], empt;
Pll query(int n, int l, int r, int d) {
  if (l > r) {
    return empt;
  }
  if (!l && r == d - 1) {
    return tree[n];
  }
  d /= 2;
  return min(query(n << 1, l, min(d - 1, r), d),
             query(n << 1 | 1, max(0, l - d), r - d, d));
}
void spetialSort(int l, int r) {
  if (l > r) return;
  int hi = -1000000000, id = -1;
  Pll temp = query(1, l, r, st);
  hi = temp.first;
  id = temp.second;
  ord[count2].first = hi;
  ord[count2++].second = id;
  spetialSort(l, id - 1);
  spetialSort(id + 1, r);
}
int main() {
  int n, q, l, r;
  empt.first = -1000000000;
  empt.second = 1000000000;
  while (scanf("%d %d", &n, &q) != EOF) {
    ord[n].first = -1000000000;
    ord[n].second = n;
    st = 1 << (int)ceil(log2(n + 1));
    tree[n + st] = ord[n];
    for (int i = int(0); i < int(n); i++) {
      scanf("%I64d", a + i);
      if (i) dif[i] = abs(a[i] - a[i - 1]);
      ord[i].first = dif[i];
      ord[i].second = i;
      tree[i + st] = ord[i];
    }
    int nn = st >> 1;
    while (nn) {
      for (int i = int(nn); i < int(nn << 1); i++) {
        tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
      }
      nn >>= 1;
    }
    count2 = 0;
    spetialSort(0, n);
    for (int i = int(0); i < int(n + 1); i++) {
      ids[ord[i].second] = i;
    }
    for (int i = int(0); i < int(q); i++) {
      scanf("%d %d", &l, &r);
      long long ans = 0, acum = 0;
      int cont = 0;
      stack<int> s;
      s.push(ids[r]);
      for (int j = int(l); j < int(r); j++) {
        while (ord[s.top()].second != j) {
          if (ord[cont].second >= j && ord[cont].second < ord[s.top()].second) {
            acum += (ord[s.top()].second - ord[cont].second) * ord[cont].first;
            s.push(cont);
          }
          cont++;
        }
        ans += acum;
        long long la = ord[s.top()].second;
        s.pop();
        acum -= (ord[s.top()].second - la) * dif[la];
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
