G. True Blue
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Retinal cone cells (Cone Cells) are mainly concentrated in the fovea of the macula and are responsible for color vision and high-resolution vision. Due to differences in their light absorption spectra, their distribution ratios are significantly asymmetric:

L-cones (long-wavelength / red): about 60% – 64%.

M-cones (medium-wavelength / green): about 30% – 32%.

S-cones (short-wavelength / blue): about 2% – 10%, and they are absent in the very center of the fovea.

This distribution explains why the human eye is most sensitive to green light (covered jointly by L and M cones), while its spatial resolution for pure blue is relatively low.

yyz likes the color blue. To find the most beautiful shade of blue, she keeps collecting it using magic. For a beautiful photo, yyz will first transform it into a blue Hilbert curve.

Specifically, there are $$$n$$$ color blocks arranged from left to right. The $$$i$$$-th block contains an amount of blue element $$$b_i$$$.

When yyz starts casting magic, she will give an incantation $$$\texttt{l r x}$$$, which means: extract all blocks in the array interval $$$[l, r]$$$ that satisfy $$$b_i \geq x$$$. After a block is extracted once, it will lose all of its blue elements.

Given $$$q$$$ magic casts, please tell yyz how many blue elements can be extracted each time.

Input

The first line contains two integers $$$n, q$$$ ($$$1 \leq n, q \leq 2 \times 10^5$$$) — the number of blocks and the number of queries.

The second line contains $$$n$$$ integers $$$b_1, b_2, \cdots, b_n$$$ ($$$1 \leq b_i \leq 10^7$$$) — the amount of blue elements in the $$$i$$$-th block.

Each of the next $$$q$$$ lines contains three integers $$$l, r, x$$$ ($$$1 \leq l \leq r \leq n$$$, $$$1 \leq x \leq 10^7$$$) — a query interval and the threshold value.

Output

Output $$$q$$$ lines. For each query, output one integer: the total amount of blue elements collected in the $$$i$$$-th magic operation.

Example
Input
3 4
86 91 70
3 3 56
2 3 1
1 1 76
1 2 52
Output
70
91
86
0
Note

yanami $$$\sim$$$