#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
const int INF = 1e9;
int a[N], b[N], num, l[N], r[N], f[N], n, m, c[N];
map<int, int> mm;
int lowbit(int x) { return x & (-x); }
int get(int x) {
  x = num - x;
  if (x <= 0) return 0;
  int s = -INF;
  for (int i = x; i; i -= lowbit(i)) s = max(s, f[i]);
  return s;
}
void add(int x, int t) {
  x = num - x;
  if (x <= 0) return;
  for (int i = x; i <= n; i += lowbit(i)) f[i] = max(f[i], t);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n - 1; i++) {
    b[i] = abs(a[i] - a[i + 1]);
    c[i] = b[i];
    mm[b[i]] = 1;
  }
  num = 0;
  for (map<int, int>::iterator it = mm.begin(); it != mm.end(); it++)
    (*it).second = ++num;
  num++;
  for (int i = 1; i < n; i++) b[i] = mm[b[i]];
  for (int i = 1; i < n; i++) {
    l[i] = get(b[i] + 1);
    add(b[i], i);
  }
  for (int i = 1; i <= n; i++) f[i] = -n;
  for (int i = n - 1; i >= 1; i--) {
    r[i] = -get(b[i]);
    add(b[i], -i);
  }
  for (int i = 1; i <= m; i++) {
    int p, q;
    scanf("%d%d", &p, &q);
    long long ans = 0;
    for (int i = p; i < q; i++) {
      long long t1 = max(p - 1, l[i]);
      long long t2 = min(q, r[i]);
      ans += (long long)(t2 - i) * (long long)(i - t1) * (long long)c[i];
    }
    cout << ans << endl;
  }
  return 0;
}
