#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, q;
  scanf("%d%d", &n, &q);
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  int d[n - 1];
  for (int i = 1; i < n; i++) d[i - 1] = abs(a[i] - a[i - 1]);
  stack<int> s;
  pair<int, int> p[n - 1];
  for (int i = 0; i < n - 1; i++) {
    while (!s.empty()) {
      int x = s.top();
      if (d[x] < d[i]) {
        s.pop();
        p[x].second = i - 1;
      } else {
        p[i].first = x + 1;
        s.push(i);
        break;
      }
    }
    if (s.empty()) {
      p[i].first = 0;
      s.push(i);
    }
  }
  while (!s.empty()) {
    int x = s.top();
    p[x].second = n - 2;
    s.pop();
  }
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    r -= 2;
    long long ans = 0;
    for (int i = l; i <= r; i++) {
      ans += (long long)d[i] * (long long)(i - (max(l, p[i].first)) + 1) *
             (long long)(min(r, p[i].second) + 1 - i);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
