#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, q, a[N], l[N], r[N];
long long get(int L, int R) {
  int j, k;
  long long ans = 0;
  for (int i = L; i <= R; i++) {
    j = max(L, l[i]);
    k = min(R, r[i]);
    ans += 1ll * (i - j + 1) * (k - i + 1) * a[i];
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) a[i] = abs(a[i] - a[i + 1]);
  a[n] = a[0] = 1000000005;
  for (int i = 1; i < n; i++) {
    l[i] = i;
    while (a[l[i] - 1] < a[i]) l[i] = l[l[i] - 1];
  }
  for (int i = n - 1; i >= 1; i--) {
    r[i] = i;
    while (a[r[i] + 1] <= a[i]) r[i] = r[r[i] + 1];
  }
  while (q--) {
    int L, R;
    cin >> L >> R;
    cout << get(L, R - 1) << endl;
  }
  return 0;
}
