5395: King of Range

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

Given n integers a1,a2,⋯,an and m queries. For each query, you are given a const k and you should determine how many different pairs (l,r) are there meeting the condition that the range of the subsequence al,al+1,⋯,ar is strictly greater than k .

Note: the range of a sequence equals the difference between the maximum and the minimum of the sequence.

输入


The first line contains two integers n,m(1≤n≤10^5,1≤m≤100), denoting the number of given integers and the number of queries respectively.The second line contains n integers a1,a2,⋯,an(1≤ai≤109) denoting the given integers.
Next m lines each contains one integer k(1≤k≤10^9), denoting the queries.

输出


Print m lines each contains one integer, denoting the answers.

样例输入 复制

5 1
1 2 3 4 5
2

样例输出 复制

3

提示


There are three pairs, (1,4),(1,5),(2,5) which meet the condition.