#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1, L = 18;
long long a[N], d[N];
long long p[N][L];
void build(int len) {
  for (int i = 0; i < len; i++) p[i][0] = i;
  for (int j = 1; (1 << j) - 1 < len; j++)
    for (int i = 0; i + (1 << j) - 1 < len; i++) {
      p[i][j] = p[i][j - 1];
      if (d[p[i][j - 1]] < d[p[i + (1 << (j - 1))][j - 1]])
        p[i][j] = p[i + (1 << (j - 1))][j - 1];
    }
}
int query(int l, int r) {
  int lg = 0;
  while (1 << (lg + 1) <= r - l + 1) lg++;
  int ind1 = p[l][lg], ind2 = p[r - (1 << lg) + 1][lg];
  if (d[ind1] > d[ind2]) return ind1;
  return ind2;
}
long long get(int l, int r) {
  if (l >= r) return 0;
  int ind = query(l, r - 1);
  long long ans =
      1LL * (ind - l + 1) * (r - ind) * d[ind] + get(l, ind) + get(ind + 1, r);
  return ans;
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", a + i);
    if (i) d[i - 1] = a[i] - a[i - 1];
    if (d[i - 1] < 0) d[i - 1] *= -1;
  }
  build(n - 1);
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%I64d\n", get(--l, --r));
  }
}
