#include <bits/stdc++.h>
using namespace std;
int Gcd(int a, int b) {
  if (b == 0) return a;
  return Gcd(b, a % b);
}
int Lcm(int a, int b) { return a / Gcd(a, b) * b; }
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 1e6 + 10;
struct SegmentTree {
  struct node {
    int l, r;
    long long mx;
  } tree[maxn << 2];
  int num[maxn];
  void pushup(int id) {
    tree[id].mx = max(tree[id << 1].mx, tree[id << 1 | 1].mx);
  }
  void build(int id, int l, int r) {
    tree[id].l = l;
    tree[id].r = r;
    if (l == r) {
      tree[id].mx = num[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(id << 1, l, mid);
    build(id << 1 | 1, mid + 1, r);
    pushup(id);
  }
  int Querymax(int id, int ql, int qr) {
    int l = tree[id].l, r = tree[id].r;
    if (ql <= l && r <= qr) return tree[id].mx;
    int mid = (l + r) >> 1;
    if (mid >= qr)
      return Querymax(id << 1, ql, qr);
    else if (ql > mid)
      return Querymax(id << 1 | 1, ql, qr);
    else
      return max(Querymax(id << 1, ql, qr), Querymax(id << 1 | 1, ql, qr));
  }
} T;
int a[maxn], k[maxn];
int L[maxn], R[maxn];
bool check1(int l, int r, int val) {
  int mx = T.Querymax(1, l, r);
  if (mx <= val)
    return true;
  else
    return false;
}
bool check2(int l, int r, int val) {
  int mx = T.Querymax(1, l, r);
  if (mx < val)
    return true;
  else
    return false;
}
int main() {
  int n = read(), q = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n - 1; i++) T.num[i] = k[i] = abs(a[i + 1] - a[i]);
  T.build(1, 1, n - 1);
  for (int i = 1; i <= n - 1; i++) {
    int l = 1, r = i;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check1(mid, i, k[i])) {
        L[i] = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    l = i + 1, r = n - 1;
    R[i] = i;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check2(i + 1, mid, k[i])) {
        R[i] = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
  }
  for (int i = 1; i <= q; i++) {
    long long ans = 0;
    int l = read(), r = read();
    for (int j = l; j <= r - 1; j++) {
      int ll = max(L[j], l), rr = min(R[j], r - 1);
      ans += 1ll * (rr - j + 1) * (j - ll + 1) * k[j];
    }
    printf("%lld\n", ans);
  }
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

A function <image> is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all <image>. We'll deal with a more... discrete version of this term.

For an array <image>, we define it's Lipschitz constant <image> as follows:

  * if n < 2, <image>
  * if n ≥ 2, <image> over all 1 ≤ i < j ≤ n



In other words, <image> is the smallest non-negative integer such that |h[i] - h[j]| ≤ L·|i - j| holds for all 1 ≤ i, j ≤ n.

You are given an array <image> of size n and q queries of the form [l, r]. For each query, consider the subarray <image>; determine the sum of Lipschitz constants of all subarrays of <image>.

Input

The first line of the input contains two space-separated integers n and q (2 ≤ n ≤ 100 000 and 1 ≤ q ≤ 100) — the number of elements in array <image> and the number of queries respectively.

The second line contains n space-separated integers <image> (<image>).

The following q lines describe queries. The i-th of those lines contains two space-separated integers li and ri (1 ≤ li < ri ≤ n).

Output

Print the answers to all queries in the order in which they are given in the input. For the i-th query, print one line containing a single integer — the sum of Lipschitz constants of all subarrays of <image>.

Examples

Input

10 4
1 5 2 9 1 3 4 2 1 7
2 4
3 8
7 10
1 9


Output

17
82
23
210


Input

7 6
5 7 7 4 6 6 2
1 2
2 3
2 6
1 7
4 7
3 5


Output

2
0
22
59
16
8

Note

In the first query of the first sample, the Lipschitz constants of subarrays of <image> with length at least 2 are:

  * <image>
  * <image>
  * <image>



The answer to the query is their sum.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int Gcd(int a, int b) {
  if (b == 0) return a;
  return Gcd(b, a % b);
}
int Lcm(int a, int b) { return a / Gcd(a, b) * b; }
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 1e6 + 10;
struct SegmentTree {
  struct node {
    int l, r;
    long long mx;
  } tree[maxn << 2];
  int num[maxn];
  void pushup(int id) {
    tree[id].mx = max(tree[id << 1].mx, tree[id << 1 | 1].mx);
  }
  void build(int id, int l, int r) {
    tree[id].l = l;
    tree[id].r = r;
    if (l == r) {
      tree[id].mx = num[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(id << 1, l, mid);
    build(id << 1 | 1, mid + 1, r);
    pushup(id);
  }
  int Querymax(int id, int ql, int qr) {
    int l = tree[id].l, r = tree[id].r;
    if (ql <= l && r <= qr) return tree[id].mx;
    int mid = (l + r) >> 1;
    if (mid >= qr)
      return Querymax(id << 1, ql, qr);
    else if (ql > mid)
      return Querymax(id << 1 | 1, ql, qr);
    else
      return max(Querymax(id << 1, ql, qr), Querymax(id << 1 | 1, ql, qr));
  }
} T;
int a[maxn], k[maxn];
int L[maxn], R[maxn];
bool check1(int l, int r, int val) {
  int mx = T.Querymax(1, l, r);
  if (mx <= val)
    return true;
  else
    return false;
}
bool check2(int l, int r, int val) {
  int mx = T.Querymax(1, l, r);
  if (mx < val)
    return true;
  else
    return false;
}
int main() {
  int n = read(), q = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n - 1; i++) T.num[i] = k[i] = abs(a[i + 1] - a[i]);
  T.build(1, 1, n - 1);
  for (int i = 1; i <= n - 1; i++) {
    int l = 1, r = i;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check1(mid, i, k[i])) {
        L[i] = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    l = i + 1, r = n - 1;
    R[i] = i;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check2(i + 1, mid, k[i])) {
        R[i] = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
  }
  for (int i = 1; i <= q; i++) {
    long long ans = 0;
    int l = read(), r = read();
    for (int j = l; j <= r - 1; j++) {
      int ll = max(L[j], l), rr = min(R[j], r - 1);
      ans += 1ll * (rr - j + 1) * (j - ll + 1) * k[j];
    }
    printf("%lld\n", ans);
  }
  return 0;
}

```