#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int l[100005];
int r[100005];
int a[100005];
int n, q;
int cnt = 0;
long long sum = 0;
void init() {
  l[1] = 1;
  for (int i = 2; i < n; i++) {
    int ans = i - 1;
    if (i - 1 >= 1 && a[i] > a[i - 1]) {
      while (ans >= 1 && a[i] > a[ans]) {
        l[i] = l[ans];
        ans = l[ans] - 1;
      }
    } else
      l[i] = i;
  };
  r[n - 1] = n - 1;
  for (int i = n - 1; i >= 1; i--) {
    int ans = i + 1;
    if (i + 1 <= n - 1 && a[i] >= a[i + 1]) {
      while (ans <= n - 1 && a[i] >= a[ans]) {
        r[i] = r[ans];
        ans = r[ans] + 1;
      }
    } else
      r[i] = i;
  }
}
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    a[i] = fabs(a[i + 1] - a[i]);
  }
  init();
  for (int i = 1; i <= q; i++) {
    long long sum = 0;
    int u, v;
    cin >> u >> v;
    for (int j = u; j < v; j++) {
      long long x = j - max(u, l[j]);
      long long y = min(v - 1, r[j]) - j;
      if (x + y)
        sum += ((x + 1) * (y + 1)) * a[j];
      else
        sum += a[j];
    }
    cout << sum << endl;
  }
  return 0;
}
