#include <bits/stdc++.h>
using namespace std;
int a[100010], top;
pair<int, int> stk[100010];
int main() {
  int n, q, l, r;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  while (q--) {
    scanf("%d%d", &l, &r);
    long long sum = 0, ans = 0;
    top = 0;
    for (int i = l + 1; i <= r; i++) {
      int now = abs(a[i] - a[i - 1]);
      while (top > 0 && stk[top - 1].first <= now) {
        if (top == 1)
          sum -=
              (long long)(stk[top - 1].second - (l - 1)) * stk[top - 1].first;
        else
          sum -= (long long)(stk[top - 1].second - stk[top - 2].second) *
                 stk[top - 1].first;
        top--;
      }
      if (top == 0)
        sum += (long long)(i - 1 - (l - 1)) * now;
      else
        sum += (long long)(i - 1 - stk[top - 1].second) * now;
      ans += sum;
      stk[top++] = pair<int, int>(now, i - 1);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
