#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, t[maxn];
int q[maxn], stk[maxn], pos[maxn];
long long sum[maxn];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
  for (int i = 1; i <= m; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    int top = 0;
    long long ans = 0;
    pos[0] = l;
    for (int i = l + 1; i <= r; ++i) {
      int value = abs(t[i] - t[i - 1]);
      while (top > 0 && stk[top] <= value) --top;
      sum[top + 1] = sum[top] + (long long)(i - pos[top]) * value;
      ans += sum[top + 1];
      stk[++top] = value;
      pos[top] = i;
    }
    cout << ans << endl;
  }
  return 0;
}
