#include <bits/stdc++.h>
using namespace std;
void solve(istream &in, ostream &out);
int main() {
  ios::sync_with_stdio(false);
  solve(cin, cout);
  return 0;
}
void solve(istream &in, ostream &out) {
  int n, q;
  in >> n >> q;
  int prev;
  in >> prev;
  vector<int> t(n - 1);
  for (int i = 0, next; i < n - 1; ++i) {
    in >> next;
    t[i] = abs(prev - next);
    prev = next;
  }
  vector<int> l(n - 1);
  vector<int> r(n - 1);
  vector<pair<int, int>> s;
  s.emplace_back(numeric_limits<int>::max(), -1);
  for (int i = 0; i < n - 1; ++i) {
    while (s.back() < make_pair(t[i], i)) {
      s.pop_back();
    }
    l[i] = s.back().second + 1;
    s.emplace_back(t[i], i);
  }
  s.clear();
  s.emplace_back(numeric_limits<int>::max(), n - 1);
  for (int i = n - 2; i >= 0; --i) {
    while (s.back() < make_pair(t[i], i)) {
      s.pop_back();
    }
    r[i] = s.back().second - 1;
    s.emplace_back(t[i], i);
  }
  for (int i = 0, a, b; i < q; ++i) {
    in >> a >> b;
    long long result = 0;
    for (long long j = a - 1; j < b - 1; ++j) {
      result += (j - (long long)max(a - 1, l[j]) + 1) *
                ((long long)min(r[j], b - 2) - j + 1) * t[j];
    }
    out << result << endl;
  }
}
