Interval Less Query#5084

Interval Less Query

1 second
128 megabytes
Easy (≈1000)

Given an array of integers a_1, a_2, \ldots, a_n, answer queries. For each query, determine how many elements of the segment [l, r] are less than .

Input

The first line contains an integer n~(1 \le n \le 2 \cdot 10^5) — the length of the array.

The second line contains integers a_1, a_2, \ldots, a_n — the elements of the array.

The third line contains an integer q~(1 \le q \le 10^5) — the number of queries.

Each of the next lines describes one query and contains three integers , and x~(1 \le l \le r \le n, 1 \le x \le 10^9).

Output

For each query, print on a separate line the number of elements a_i with l \le i \le r such that a_i < x.

Examples

Example 1

Loading
Loading