Vision Field

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 256000/128000KB (Java/Others)

Problem Description

There are N buildings stand along the horizon line.

Each building are been represented as a vertical segment with two end points at (i, 0) and (i, Ai).

There are M queries in total.

For each query, we wonder know how many buildings you can see if you stand at (0, h).

N, M ≤ 10^6, both Ai && h is positive interger and ≤ 10^9.

Input

n

A1 A2 ... An

m...

(here following the m query.)

Output

For each query, print the result on a single line.

Sample Input

5
2 3 3 3 4
3
3
2
4

Sample Output

3
2
5

Hint

x 轴正半轴上分布着 n 个楼房 (i, Ai),问站在 (0, h) 往右可以看到多少楼房。

Source

xiaodao

Manager

Information
Solved Number3
Submit Number7
Problem Tags
geometry
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel