#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = 2 * acos(0);
const int maxn = 100010;
int n, q;
int a[maxn];
int d[maxn];
int l[maxn];
int r[maxn];
void solve() {
  scanf("%d%d", &n, &q);
  for (int i = (0); i < (n); i++) scanf("%d", a + i);
  for (int i = (0); i < (n - 1); i++) d[i] = abs(a[i + 1] - a[i]);
  for (int i = (0); i < (n - 1); i++) l[i] = r[i] = i;
  for (int i = (1); i < (n - 1); i++) {
    int cur = i;
    while (cur > 0 && d[cur - 1] <= d[i]) cur = l[cur - 1];
    l[i] = cur;
  }
  for (int i = (n - 2) - 1; i >= (0); i--) {
    int cur = i;
    while (cur < n - 2 && d[cur + 1] < d[i]) cur = r[cur + 1];
    r[i] = cur;
  }
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y -= 2;
    long long ans = 0;
    for (int i = (x); i < (y + 1); i++) {
      int u = i - max(x, l[i]);
      int v = min(y, r[i]) - i;
      if (u >= 0 && v >= 0) ans += 1LL * d[i] * (u + 1) * (v + 1);
    }
    printf("%I64d\n", ans);
  }
}
int main() {
  solve();
  return 0;
}
