#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int n;
int a[N];
long long query(int l, int r) {
  vector<pair<long long, long long> > stack;
  long long ret = 0;
  long long cur = 0;
  for (int i = l + 1; i <= r; ++i) {
    long long diff = abs(a[i] - a[i - 1]);
    long long tot = 1;
    for (; stack.size();) {
      if (stack.back().first <= diff) {
        tot += stack.back().second;
        cur -= stack.back().first * stack.back().second;
        stack.pop_back();
      } else {
        break;
      }
    }
    stack.push_back(make_pair(diff, tot));
    cur += diff * tot;
    ret += cur;
  }
  return ret;
}
void solve() {
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (; q--;) {
    int l, r;
    scanf("%d%d", &l, &r);
    --l, --r;
    cout << query(l, r) << endl;
  }
}
int main() {
  solve();
  return 0;
}
