#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > matmul(vector<vector<long long> > &a,
                                  vector<vector<long long> > &b) {
  int i, j, k, n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      long long temp = 0;
      for (k = 0; k < n; k++)
        temp = (temp + a[i][k] * b[k][j]) % (1000000007LL);
      ans[i][j] = temp;
    }
  return ans;
}
vector<vector<long long> > matpwr(vector<vector<long long> > &a, long long p) {
  int n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (int i = 0; i < n; i++) ans[i][i] = 1;
  while (p) {
    if (p & 1) ans = matmul(ans, a);
    a = matmul(a, a);
    p >>= 1;
  }
  return ans;
}
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long invMod(long long n, long long mod = (1000000007LL)) {
  return pwr(n, mod - 2);
}
int n, arr[100005];
int main() {
  ios_base::sync_with_stdio(0);
  int q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  while (q--) {
    int a, b;
    cin >> a >> b;
    long long ans = 0, temp = 0;
    stack<pair<long long, long long> > st;
    for (int i = a + 1; i <= b; i++) {
      long long val = abs(arr[i] - arr[i - 1]);
      long long cnt = 1;
      while (!st.empty() && st.top().first < val) {
        cnt += st.top().second;
        temp -= st.top().first * st.top().second;
        st.pop();
      }
      st.push(pair<long long, long long>(val, cnt));
      temp += val * cnt;
      ans += temp;
    }
    cout << ans << endl;
  }
  return 0;
}
