#include <bits/stdc++.h>
using namespace std;
int n, q;
long long s[100005];
void init() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%I64d", &s[i]);
}
void process() {
  int l, r;
  for (int cnt = 0; cnt < q; cnt++) {
    scanf("%d%d", &l, &r);
    long long ans = 0;
    vector<pair<int, long long> > v;
    long long tans = 0;
    for (int i = l + 1; i <= r; i++) {
      int tl = i;
      long long tmp = abs(s[i] - s[i - 1]);
      while (v.size() && v.back().second < tmp) {
        tans -= (tl - v.back().first) * v.back().second;
        tl = v.back().first;
        v.pop_back();
      }
      tans += (long long)(i + 1 - tl) * tmp;
      v.emplace_back(tl, tmp);
      ans += tans;
    }
    printf("%I64d\n", ans);
  }
}
int main() {
  init();
  process();
  return 0;
}
