## 14 Apr Friday 17:00 Python Practice 21.04.09.

**Question:**

Mr. Ken is upset because of his short height. Now, he wants to imagine himself taller. So he decided to stand in front of K pillars of different heights i.e. the j_{th} pillar has height h_{i}. Now to feel taller, he wanted to know how many buildings he is able to see within the range [l,r] both inclusive?

**Input Specification:**

The first line contains an integer K denoting the number of pillars.

The next line contains K integers denoting the height of j_{th} pillar.

The next line contains a single integer Q (number of queries).

Next, Q lines contain pairs l and r respectively.

**Output Specification**For every Q queries print the number of buildings visible in the range [l, r].

Sample Input7 5 2 3 7 9 8 11 4 0 6 1 5 2 6 3 4Sample Output4 4 4 2ExplanationIn query 1- 5, 7, 9, 11 pillars are visible so the answer is 4. In query 2 -2, 3, 7, 9 are visible so the answer is 4.

Sorry, the comment form is closed at this time.