#include <bits/stdc++.h>
using namespace std;
int n, q, m;
int a[100005];
pair<int, int> tree1[400005];
void build1(int lo, int hi, int id) {
  if (lo > hi) return;
  if (lo == hi) {
    tree1[id] = {a[lo], lo};
    return;
  }
  int mid = (lo + hi) / 2;
  build1(lo, mid, 2 * id);
  build1(mid + 1, hi, 2 * id + 1);
  tree1[id] = max(tree1[2 * id], tree1[2 * id + 1]);
}
pair<int, int> range_max_query(int lo, int hi, int l, int r, int id) {
  if (lo > hi) return {0, -1};
  if (l > hi || lo > r) return {0, -1};
  if (lo >= l && hi <= r) return tree1[id];
  int mid = (lo + hi) / 2;
  pair<int, int> lc = range_max_query(lo, mid, l, r, 2 * id);
  pair<int, int> rc = range_max_query(mid + 1, hi, l, r, 2 * id + 1);
  return max(lc, rc);
}
long long int ans;
void solve(int l, int r) {
  if (l > r) return;
  if (l == r) {
    ans += a[l];
    return;
  }
  pair<int, int> id = range_max_query(0, n - 1, l, r, 1);
  long long int t = (id.second - l + 1);
  t = t * (r - id.second + 1);
  t = t * (id.first);
  ans += t;
  solve(l, id.second - 1);
  solve(id.second + 1, r);
  return;
}
map<pair<int, int>, long long int> mymap;
int main() {
  std::ios::sync_with_stdio(false);
  scanf("%d%d", &n, &q);
  int prev = -1;
  for (int i = 0; i <= n - 1; i++) {
    int x;
    scanf("%d\n", &x);
    if (prev != -1) a[i - 1] = abs(x - prev);
    prev = x;
  }
  n--;
  build1(0, n - 1, 1);
  for (int i = 1; i <= q; i++) {
    ans = 0;
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    r--;
    r--;
    if (mymap[{l, r}]) {
      long long int temp = mymap[{l, r}];
      printf("%I64d\n", temp);
      continue;
    }
    solve(l, r);
    mymap[{l, r}] = ans;
    printf("%I64d\n", ans);
  }
  return 0;
}
