#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 100100;
long long int t[maxn], a[maxn], l[maxn], r[maxn];
long long int ans;
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) t[i] = abs(a[i] - a[i + 1]);
  for (int i = 1; i < n; i++) {
    l[i] = 0;
    r[i] = n;
  }
  for (int i = 2; i < n; i++) {
    int cur = i - 1;
    while (cur > 0 && t[cur] <= t[i]) cur = l[cur];
    l[i] = cur;
  }
  for (int i = n - 2; i > 0; i--) {
    int cur = i + 1;
    while (cur < n && t[cur] < t[i]) cur = r[cur];
    r[i] = cur;
  }
  for (int cnt = 1; cnt <= q; cnt++) {
    ans = 0;
    long long int L, R;
    cin >> L >> R;
    for (int i = L; i <= R; i++)
      ans += ((min(r[i], R) - i) * (i - max(l[i], L - 1))) * t[i];
    cout << ans << endl;
  }
}
