#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T>
inline void gmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
  if (b < a) a = b;
}
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, ms63 = 1061109567;
int n, m;
int l, r;
int vv[N], v[N], L[N], R[N];
int b[18];
int f[N][18];
void RMQinit() {
  int L = log(n + 0.5) / log(2.0);
  for (int j = 0; j <= L; ++j) b[j] = 1 << j;
  for (int i = 1; i <= n; ++i) f[i][0] = v[i];
  for (int j = 1; j <= L; ++j) {
    int len = b[j - 1] - 1;
    for (int i = 1; i + len <= n; ++i) {
      f[i][j] = max(f[i][j - 1], f[i + b[j - 1]][j - 1]);
    }
  }
}
int RMQmax(int l, int r) {
  int len = r - l + 1;
  int k = log(len + 0.5) / log(2.0);
  return max(f[l][k], f[r - b[k] + 1][k]);
}
void init() {
  int l, r;
  for (int i = 1; i <= n; ++i) {
    l = 1;
    r = i;
    while (l < r) {
      int m = (l + r) >> 1;
      if (RMQmax(m, i - 1) < v[i])
        r = m;
      else
        l = m + 1;
    }
    L[i] = l;
    l = i, r = n;
    while (l < r) {
      int m = (l + r + 1) >> 1;
      if (RMQmax(i + 1, m) <= v[i])
        l = m;
      else
        r = m - 1;
    }
    R[i] = l;
  }
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; ++i) scanf("%d", &vv[i]);
    --n;
    for (int i = 1; i <= n; ++i) v[i] = abs(vv[i + 1] - vv[i]);
    RMQinit();
    init();
    for (int i = 1; i <= m; ++i) {
      scanf("%d%d", &l, &r);
      --r;
      long long ans = 0;
      for (int j = l; j <= r; ++j)
        ans +=
            (long long)(j - max(L[j], l) + 1) * (min(R[j], r) - j + 1) * v[j];
      printf("%lld\n", ans);
    }
  }
  return 0;
}
