#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
pair<int, int> t[4 * 100001];
pair<int, int> combine(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return a;
  if (b.first > a.first) return b;
  return make_pair(a.first, a.second + b.second);
}
void build(int a[], int v, int tl, int tr) {
  if (tl == tr)
    t[v] = make_pair(a[tl], 1);
  else {
    int tm = (tl + tr) / 2;
    build(a, v * 2, tl, tm);
    build(a, v * 2 + 1, tm + 1, tr);
    t[v] = combine(t[v * 2], t[v * 2 + 1]);
  }
}
pair<int, int> get_max(int v, int tl, int tr, int l, int r) {
  if (l > r) return make_pair(-9999999999, 0);
  if (l == tl && r == tr) return t[v];
  int tm = (tl + tr) / 2;
  return combine(get_max(v * 2, tl, tm, l, min(r, tm)),
                 get_max(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void update(int v, int tl, int tr, int pos, int new_val) {
  if (tl == tr)
    t[v] = make_pair(new_val, 1);
  else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, new_val);
    else
      update(v * 2 + 1, tm + 1, tr, pos, new_val);
    t[v] = combine(t[v * 2], t[v * 2 + 1]);
  }
}
int main() {
  int n, m, k, q;
  string s;
  long long ans = 0;
  scanf("%d %d", &n, &q);
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  std::vector<int> b(n - 1);
  std::vector<std::pair<int, int> > so;
  for (int i = 0; i < n - 1; i++) {
    b[i] = abs(a[i] - a[i + 1]);
  }
  deque<std::pair<int, int> > val;
  val.push_back(make_pair(b[0], 0));
  std::vector<int> nx(n - 1);
  std::vector<int> px(n - 1);
  for (int i = 1; i < n - 1; i++) {
    while ((val.size() > 0) && (val.back().first < b[i])) {
      nx[val.back().second] = i;
      val.pop_back();
    }
    val.push_back(make_pair(b[i], i));
  }
  while (val.size() > 0) {
    nx[val.back().second] = n - 1;
    val.pop_back();
  }
  val.push_back(make_pair(b[n - 2], n - 2));
  for (int i = n - 3; i >= 0; i--) {
    while ((val.size() > 0) && (val.back().first <= b[i])) {
      px[val.back().second] = i;
      val.pop_back();
    }
    val.push_back(make_pair(b[i], i));
  }
  while (val.size() > 0) {
    px[val.back().second] = -1;
    val.pop_back();
  }
  build(b.data(), 1, 0, n - 2);
  for (int i = 0; i < q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    std::vector<std::pair<int, int> > si;
    long long ans = 0;
    for (int j = x; j < y; j++) {
      ans += 1ll * b[j] * (j - max(x - 1, px[j])) * (min(y, nx[j]) - j);
    }
    printf("%I64d\n", ans);
  }
}
