#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
const int MAXN = 100010;
int n, q;
int A[MAXN], B[MAXN];
int L[MAXN], R[MAXN];
set<pair<int, int> > st;
set<pair<int, int> >::iterator it;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i < n; ++i) {
    B[i] = abs(A[i + 1] - A[i]);
  }
  for (int i = 1; i < n; ++i) {
    L[i] = 1;
    R[i] = n - 1;
  }
  for (int i = 1; i < n; ++i) {
    st.insert(make_pair(B[i], i));
    it = st.find(make_pair(B[i], i));
    vector<pair<int, int> > g;
    while (1) {
      if (it == st.begin()) break;
      it--;
      if ((*it).first <= B[i]) {
        R[(*it).second] = i - 1;
        g.push_back((*it));
      }
    }
    for (int j = 0; j < g.size(); ++j) st.erase(g[j]);
  }
  st.clear();
  for (int i = n - 1; i >= 1; --i) {
    st.insert(make_pair(B[i], i));
    it = st.find(make_pair(B[i], i));
    vector<pair<int, int> > g;
    while (1) {
      if (it == st.begin()) break;
      it--;
      if ((*it).first < B[i]) {
        L[(*it).second] = i + 1;
        g.push_back((*it));
      }
    }
    for (int j = 0; j < g.size(); ++j) st.erase(g[j]);
  }
  for (int i = 1; i <= q; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    long long ans = 0;
    for (int j = a; j < b; ++j) {
      int l = max(a, L[j]);
      int r = min(b - 1, R[j]);
      long long num;
      if (l == r)
        num = 1;
      else
        num = 1ll * (r - j + 1) * (j - l + 1);
      ans += 1ll * B[j] * num;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
