#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma warning(disable : 4996)
using namespace std;
const long long maxn = 1e5 + 5;
const long long shift = 150;
const long long K = 301;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 1;
long long a[maxn];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  while (m--) {
    long long l, r;
    cin >> l >> r;
    vector<long long> b;
    long long ans = 0;
    long long cur = 0;
    for (long long i = l; i < r; i++) b.push_back(abs(a[i] - a[i - 1]));
    vector<pair<long long, long long> > wh;
    for (long long i = 0; i < b.size(); i++) {
      long long nowsz = 1;
      while (!wh.empty() && wh.back().first < b[i]) {
        cur -= wh.back().first * wh.back().second;
        nowsz += wh.back().second;
        wh.pop_back();
      }
      cur += nowsz * b[i];
      ans += cur;
      wh.push_back({b[i], nowsz});
    }
    cout << ans << '\n';
  }
  return 0;
}
