#include <bits/stdc++.h>
using namespace std;
struct rec {
  int x, w;
  rec() {}
  rec(int a, int b) {
    x = a;
    w = b;
  }
};
deque<rec> que;
int a[100010], b[100010], l[100010], r[100010];
int n, q;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i < n; ++i) b[i] = abs(a[i + 1] - a[i]);
  while (!que.empty()) que.pop_back();
  for (int i = 1; i < n; ++i) {
    while (!que.empty() && que.back().w < b[i]) que.pop_back();
    if (que.empty())
      l[i] = 1;
    else
      l[i] = que.back().x + 1;
    que.push_back(rec(i, b[i]));
  }
  while (!que.empty()) que.pop_back();
  for (int i = n - 1; i > 0; --i) {
    while (!que.empty() && que.back().w <= b[i]) que.pop_back();
    if (que.empty())
      r[i] = n - 1;
    else
      r[i] = que.back().x - 1;
    que.push_back(rec(i, b[i]));
  }
  long long ans;
  int x, y;
  for (int i = 1; i <= q; ++i) {
    ans = 0;
    scanf("%d%d", &x, &y);
    for (int j = x; j < y; ++j) {
      ans +=
          (long long)b[j] * (j - max(x, l[j]) + 1) * (min(y - 1, r[j]) - j + 1);
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
