#include <bits/stdc++.h>
using namespace std;
int N, Q;
int a[100010];
int ql[110], qr[110];
long long ans[110];
void query(int L, int M, int R, long long x) {
  int i;
  for ((i) = 0; (i) < (int)(Q); (i)++)
    if (ql[i] < M && qr[i] > M) {
      long long tmp1 = M - max(L, ql[i]);
      long long tmp2 = min(R, qr[i]) - M;
      ans[i] += tmp1 * tmp2 * x;
    }
}
int main(void) {
  int i, j;
  cin >> N >> Q;
  for ((i) = 0; (i) < (int)(N); (i)++) scanf("%d", &a[i]);
  for ((i) = 0; (i) < (int)(Q); (i)++) {
    scanf("%d%d", &ql[i], &qr[i]);
    ql[i]--;
  }
  set<int> s;
  s.insert(0);
  s.insert(N);
  vector<pair<int, int> > v;
  for (i = 1; i < N; i++) {
    int tmp = a[i] - a[i - 1];
    if (tmp < 0) tmp = -tmp;
    v.push_back(make_pair(tmp, i));
  }
  sort(v.begin(), v.end());
  int sz = v.size();
  for (i = sz - 1; i >= 0; i--) {
    long long d = v[i].first;
    int id = v[i].second;
    s.insert(id);
    __typeof(s.begin()) itr = s.find(id);
    itr--;
    int L = *(itr);
    itr++;
    itr++;
    int R = *(itr);
    query(L, id, R, d);
  }
  for ((i) = 0; (i) < (int)(Q); (i)++) cout << ans[i] << endl;
  return 0;
}
