#include <bits/stdc++.h>
using namespace std;
int point[100009];
int slope[100009];
long long int Find_sum(int l, int r) {
  int array[100009];
  int right[100009];
  int left[100009];
  int n = r - l;
  for (int i = l; i < r; i++) {
    array[i - l] = abs(slope[i]);
  }
  {
    stack<int> S;
    S.push(0);
    int i = 1;
    while (i < n) {
      if (array[i] <= array[S.top()]) {
        S.push(i);
      } else {
        while (array[i] > array[S.top()]) {
          right[S.top()] = i - 1;
          S.pop();
          if (S.empty()) break;
        }
        S.push(i);
      }
      i++;
    }
    while (!S.empty()) {
      right[S.top()] = n - 1;
      S.pop();
    }
  }
  {
    stack<int> S;
    int i = n - 1;
    S.push(i);
    i--;
    while (i >= 0) {
      if (array[i] < array[S.top()]) {
        S.push(i);
      } else {
        while (array[i] >= array[S.top()]) {
          left[S.top()] = i + 1;
          S.pop();
          if (S.empty()) break;
        }
        S.push(i);
      }
      i--;
    }
    while (!S.empty()) {
      left[S.top()] = 0;
      S.pop();
    }
  }
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    long long int k1 = right[i] - left[i] + 2;
    long long int k2 = left[i] <= (i - 1) ? (i - 1 - left[i] + 1 + 1) : 1;
    long long int k3 = (i + 1) <= right[i] ? (right[i] - (i + 1) + 1 + 1) : 1;
    long long int temp =
        ((k1 * (k1 - 1) - k2 * (k2 - 1) - k3 * (k3 - 1)) * abs(array[i])) / 2;
    sum += temp;
  }
  cout << endl;
  return sum;
}
int main() {
  int n, q;
  scanf("%d", &n);
  scanf("%d", &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &point[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    slope[i] = point[i + 1] - point[i];
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%d", &l);
    scanf("%d", &r);
    l--;
    r--;
    cout << Find_sum(l, r) << endl;
  }
  return 0;
}
