#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
using namespace std;
int dp[(int)1e5 + 5][22];
int a[(int)1e5 + 5], n, q;
int diff[(int)1e5 + 5];
void comp() {
  int i, j;
  int x = n - 1;
  for (i = 0; i < x; i++) {
    dp[i][0] = diff[i];
  }
  for (i = 1; (1 << i) <= x; i++) {
    for (j = 0; j + (1 << i) - 1 < x; j++) {
      dp[j][i] = max(dp[j][i - 1], dp[j + (1 << (i - 1))][i - 1]);
    }
  }
}
int query(int i, int j) {
  int k = (j - i + 1);
  int p = 0;
  while ((1 << p) <= k) p++;
  p--;
  if (dp[i][p] >= dp[j - (1 << p) + 1][p])
    return dp[i][p];
  else
    return dp[j - (1 << p) + 1][p];
}
vector<pair<int, int> > v;
int get() {
  char c;
  while (c = getchar(), (c < '0' || c > '9') && (c != '-'))
    ;
  bool flag = (c == '-');
  if (flag) c = getchar();
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return flag ? -x : x;
}
void output(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int len = 0, data[20];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
  putchar('\n');
}
int main() {
  int i, j;
  n = get();
  q = get();
  for (i = 0; i < n; i++) a[i] = get();
  for (i = 0; i < n - 1; i++) diff[i] = abs(a[i] - a[i + 1]);
  comp();
  for (j = 0; j <= n - 2; j++) {
    int lo = 0, hi = j;
    while (lo < hi) {
      int mid = (lo + hi) >> 1;
      if (query(mid, j - 1) >= diff[j])
        lo = mid + 1;
      else
        hi = mid;
    }
    int L = lo;
    lo = j;
    hi = n - 2;
    while (lo < hi) {
      int mid = (lo + hi + 1) >> 1;
      if (query(j, mid) > diff[j])
        hi = mid - 1;
      else
        lo = mid;
    }
    v.push_back(make_pair(L, lo));
  }
  while (q--) {
    int x, y;
    x = get();
    y = get();
    x--;
    y -= 2;
    long long ans = 0;
    for (j = x; j <= y; j++) {
      int L = max(v[j].first, x);
      int lo = min(v[j].second, y);
      long long acl = j - 1;
      long long acr = lo + 1;
      long long x = diff[j];
      ans += (acr - j) * x;
      ans += ((j + 1) - L) * x;
      ans += (acl - L + 1) * (acr - (j + 2) + 1) * x;
      ans -= x;
    }
    output(ans);
  }
  return 0;
}
