## KQUERY - K-query

English | Vietnamese |

Given a sequence of n numbers a_{1}, a_{2}, ..., a_{n} and a number of k- queries. A k-query is a triple (i, j, k) (1 ≤ i ≤ j ≤ n). For each k-query (i, j, k), you have to return the number of elements greater than k in the subsequence a_{i}, a_{i+1}, ..., a_{j}.

### Input

- Line 1: n (1 ≤ n ≤ 30000).
- Line 2: n numbers a
_{1}, a_{2}, ..., a_{n}(1 ≤ a_{i}≤ 10^{9}). - Line 3: q (1 ≤ q ≤ 200000), the number of k- queries.
- In the next q lines, each line contains 3 numbers i, j, k representing a k-query (1 ≤ i ≤ j ≤ n, 1 ≤ k ≤ 10
^{9}).

### Output

- For each k-query (i, j, k), print the number of elements greater than k in the subsequence a
_{i}, a_{i+1}, ..., a_{j}in a single line.

### Example

Input5 5 1 2 3 4 3 2 4 1 4 4 4 1 5 2Output2 0 3

Added by: | Jimmy |

Date: | 2008-10-26 |

Time limit: | 1s |

Source limit: | 50000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |

Resource: | Gomoku |