#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; (i) < (n); ++(i)) cin >> a[i];
  vector<int> b(n - 1);
  for (int i = 0; (i) < (n - 1); ++(i)) b[i] = abs(a[i + 1] - a[i]);
  for (int qi = 0; (qi) < (q); ++(qi)) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    long long result = 0;
    long long acc = 0;
    map<int, int> f;
    for (int i = (l); (i) < (r); ++(i)) {
      int cnt = 0;
      for (auto it = f.begin(); it != f.end();) {
        if (b[i] <= it->first) break;
        cnt += it->second;
        acc += (((long long)b[i]) - it->first) * it->second;
        it = f.erase(it);
      }
      acc += b[i];
      f[b[i]] += cnt + 1;
      result += acc;
    }
    cout << result << endl;
  }
  return 0;
}
