#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int MX = 1e9 + 7;
const long long int INF = 1e18 + 9LL;
int n, q;
int in[N];
int diff[N];
vector<pair<int, int> > V;
long long int solve(int from, int to) {
  long long int ret = 0LL;
  for (int i = from; i <= to; ++i) {
    int cur = i;
    while (V.size()) {
      if (diff[V.back().first] > diff[i]) break;
      ret += 1LL * diff[V.back().first] * (i - V.back().first) *
             (V.back().first - V.back().second + 1);
      cur = V.back().second;
      V.pop_back();
    }
    V.push_back({i, cur});
  }
  ++to;
  while (V.size()) {
    ret += 1LL * diff[V.back().first] * (to - V.back().first) *
           (V.back().first - V.back().second + 1);
    V.pop_back();
  }
  return ret;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; ++i) scanf("%d", &in[i]);
  for (int i = 1; i < n; ++i) diff[i] = abs(in[i + 1] - in[i]);
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%lld\n", solve(l, r - 1));
  }
  return 0;
}
