#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int SIZE = 3e5 + 5;
const long long INF = 1000000000000000000LL;
int rd[100009];
long long d[100009];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < (n); ++i) scanf("%d", &(rd[i]));
  for (int i = 0; i < (n - 1); ++i) {
    d[i] = abs(rd[i + 1] - rd[i]);
  }
  for (int it = 0; it < (q); ++it) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    if (a == b) {
      printf("0\n");
    }
    vector<pair<long long, long long> > v;
    long long ans = 0;
    long long cv = 0;
    v.push_back(make_pair(1 << 30, a - 1));
    for (int i = (a); i < (b); ++i) {
      while (v.back().first <= d[i]) {
        if (v.size() > 1)
          cv -= (long long)v.back().first *
                (long long)(v[v.size() - 1].second - v[v.size() - 2].second);
        v.pop_back();
      }
      v.push_back(make_pair(d[i], i));
      if (v.size() > 1)
        cv += (long long)v.back().first *
              (long long)(v[v.size() - 1].second - v[v.size() - 2].second);
      ans += cv;
    }
    printf("%I64d\n", ans);
  }
}
