#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int IT_MAX;
const int MOD = 500500507;
const int INF = 1034567891;
const long long LL_INF = 2234567890123456789ll;
const double PI = 3.141592653589793238;
int in[100050];
int u[100050];
int l[100050];
int r[100050];
vector<pair<int, int> > V;
int main() {
  int N, Q, i, j, t1, t2;
  scanf("%d %d", &N, &Q);
  for (i = 1; i <= N; i++) scanf("%d", &u[i]);
  for (i = 1; i < N; i++) in[i] = -abs(u[i + 1] - u[i]);
  N--;
  l[1] = 1;
  V.push_back(pair<int, int>(in[1], 1));
  for (i = 2; i <= N; i++) {
    while (!V.empty() && V.back().first >= in[i]) V.pop_back();
    if (V.empty())
      l[i] = 1;
    else
      l[i] = V.back().second + 1;
    V.push_back(pair<int, int>(in[i], i));
  }
  V.clear();
  r[N] = N;
  V.push_back(pair<int, int>(in[N], N));
  for (i = N - 1; i >= 1; i--) {
    while (!V.empty() && V.back().first > in[i]) V.pop_back();
    if (V.empty())
      r[i] = N;
    else
      r[i] = V.back().second - 1;
    V.push_back(pair<int, int>(in[i], i));
  }
  while (Q--) {
    scanf("%d %d", &t1, &t2);
    t2--;
    long long ans = 0;
    for (i = t1; i <= t2; i++) {
      int x = max(t1, l[i]), y = min(t2, r[i]);
      ans += (long long)(i - x + 1) * (y - i + 1) * in[i];
    }
    printf("%lld\n", -ans);
  }
  return 0;
}
