#include <bits/stdc++.h>
using namespace ::std;
const int N = 100000;
int n, m;
long long a[N + 5];
int uf[N + 5];
long long s[N + 5];
int up(int now) {
  if (uf[now] == now) return now;
  return uf[now] = up(uf[now]);
}
void uf_merge(int v1, int v2) {
  int w1 = up(v1), w2 = up(v2);
  if (w1 != w2) {
    uf[w1] = w2;
    s[w2] += s[w1];
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 0; i < m; i++) {
    int l, r;
    long long ans = 0;
    scanf("%d %d", &l, &r);
    for (int j = l; j <= r; j++) uf[j] = j, s[j] = 1;
    vector<pair<long long, int> > v;
    for (int j = l; j < r; j++)
      v.push_back(pair<long long, int>(abs(a[j + 1] - a[j]), j));
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      int v1 = up(v[i].second);
      int v2 = up(v[i].second + 1);
      ans += v[i].first * s[v1] * s[v2];
      uf_merge(v[i].second, v[i].second + 1);
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
