#include <bits/stdc++.h>
const double EPS = 1e-10;
using namespace std;
inline int rit() {
  int f = 0, key = 1;
  char c;
  do {
    c = getchar();
    if (c == '-') key = -1;
  } while (c < '0' || c > '9');
  do {
    f = f * 10 + c - '0';
    c = getchar();
  } while (c >= '0' && c <= '9');
  return f * key;
}
const int Z = 100005;
int n, q;
int a[Z], d[Z], tree[4 * Z];
void build(int pos, int L, int R) {
  int mid = (L + R) / 2;
  if (L == R) {
    tree[pos] = d[L];
    return;
  }
  build(pos * 2, L, mid);
  build(pos * 2 + 1, mid + 1, R);
  tree[pos] = max(tree[pos * 2], tree[pos * 2 + 1]);
  return;
}
int ask(int pos, int L, int R, int QL, int QR) {
  int mid = (L + R) / 2;
  if (L == QL && R == QR) {
    return tree[pos];
  }
  if (QR <= mid) {
    return ask(pos * 2, L, mid, QL, QR);
  } else if (QL > mid) {
    return ask(pos * 2 + 1, mid + 1, R, QL, QR);
  } else
    return max(ask(pos * 2, L, mid, QL, mid),
               ask(pos * 2 + 1, mid + 1, R, mid + 1, QR));
}
void read() {
  int i;
  n = rit(), q = rit();
  for (i = 1; i <= n; i++) {
    a[i] = rit();
  }
  for (i = 1; i < n; i++) {
    d[i] = abs(a[i] - a[i + 1]);
  }
}
long long Lex[Z], Rex[Z];
void calc() {
  long long sm, bi, mid;
  int i;
  for (i = 1; i < n; i++) {
    bi = i - 1;
    sm = 0;
    while (bi - sm > 1) {
      mid = (bi + sm) / 2;
      if (ask(1, 1, n - 1, i - mid, i) == d[i]) {
        sm = mid;
      } else
        bi = mid;
    }
    if (ask(1, 1, n - 1, i - bi, i) == d[i])
      Lex[i] = bi;
    else
      Lex[i] = sm;
    if (i == n - 1) {
      Rex[i] = 0;
      continue;
    }
    bi = n - 1 - i;
    sm = 0;
    mid = (bi + sm) / 2;
    while (bi - sm > 1) {
      mid = (bi + sm) / 2;
      if (mid == 0) break;
      if (ask(1, 1, n - 1, i + 1, i + mid) < d[i]) {
        sm = mid;
      } else
        bi = mid;
    }
    if (mid == 0) {
      if (ask(1, 1, n - 1, i + 1, i + 1) < d[i])
        Rex[i] = 1;
      else
        Rex[i] = 0;
    } else {
      if (ask(1, 1, n - 1, i + 1, i + bi) < d[i])
        Rex[i] = bi;
      else
        Rex[i] = sm;
    }
  }
}
void solve() {
  int i, j;
  long long a, b, L, R;
  long long ans, num;
  build(1, 1, n - 1);
  calc();
  for (i = 0; i < q; i++) {
    a = rit(), b = rit() - 1;
    for (j = a, ans = 0; j <= b; j++) {
      L = max(a, j - Lex[j]);
      R = min(b, j + Rex[j]);
      num = (j - L + 1) * (R - j + 1);
      ans += (num) * (long long)(d[j]);
    }
    cout << ans << endl;
  }
}
int main() {
  int nn = 1;
  while (nn--) {
    read();
    solve();
  }
  return 0;
}
