#include <bits/stdc++.h>
int v[100000], st[100001];
int main() {
  int n, q, i, x, y, j, vf;
  long long ans;
  fscanf(stdin, "%d%d", &n, &q);
  for (i = 0; i < n; i++) {
    fscanf(stdin, "%d", &v[i]);
  }
  n--;
  for (i = 0; i < n; i++) {
    v[i] = v[i + 1] - v[i];
    if (v[i] < 0) {
      v[i] = -v[i];
    }
  }
  for (i = 0; i < q; i++) {
    fscanf(stdin, "%d%d", &x, &y);
    x--;
    y--;
    y--;
    ans = 0;
    vf = 0;
    st[0] = x - 1;
    for (j = x; j <= y; j++) {
      while ((vf > 0) && (v[j] >= v[st[vf]])) {
        ans += 1LL * v[st[vf]] * (st[vf] - st[vf - 1]) * (j - st[vf]);
        vf--;
      }
      st[++vf] = j;
    }
    while (vf > 0) {
      ans += 1LL * v[st[vf]] * (st[vf] - st[vf - 1]) * (j - st[vf]);
      vf--;
    }
    fprintf(stdout, "%I64d\n", ans);
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
