#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 5, MOD = 1e9 + 7, INF = 1e9;
const double PI = acos(-1), eps = 1e-7;
int n, q, A[maxN], D[maxN];
long long r[maxN], l[maxN], st[maxN];
int main() {
  cin >> n >> q;
  for (int i = int(1); i < int(n + 1); i++) {
    cin >> A[i];
  }
  A[0] = A[n + 1] = INF;
  for (int i = int(1); i < int(n + 1); i++) {
    D[i - 1] = abs(A[i] - A[i - 1]);
  }
  D[n] = D[0];
  int top = 0;
  memset(r, 0, sizeof r);
  for (int i = int(1); i < int(n + 1); i++) {
    while (top > 0 && D[i] > D[st[top - 1]]) {
      r[st[--top]] = i;
    }
    st[top++] = i;
  }
  for (int i = int(1); i < int(n); i++) {
    r[i] -= i + 1;
  }
  top = 0;
  memset(l, 0, sizeof l);
  for (int i = n - 1; i >= 0; i--) {
    while (top > 0 && D[i] >= D[st[top - 1]]) {
      l[st[--top]] = i;
    }
    st[top++] = i;
  }
  for (int i = int(1); i < int(n); i++) {
    l[i] = i - l[i] - 1;
  }
  long long a, b, L, R;
  for (int i = int(0); i < int(q); i++) {
    cin >> a >> b;
    b--;
    long long ans = 0;
    for (int j = int(a); j < int(b + 1); j++) {
      L = min(l[j], j - a);
      R = min(r[j], b - j);
      L++, R++;
      ans += L * R * D[j];
    }
    cout << ans << '\n';
  }
}
