#K55402. Unique Side Length Count

    ID: 29967 Type: Default 1000ms 256MiB

Unique Side Length Count

Unique Side Length Count

You are given an array of integers that represent the side lengths of square papers. Your task is to answer several queries about the array. Each query contains two integers (l) and (r), which denote a range in the array (1-indexed). For each query, you need to count the number of distinct side lengths in the interval ([l, r]).

inputFormat

The input is read from standard input (stdin). The first line contains an integer (n), the number of elements in the array. The second line contains (n) space-separated integers representing the side lengths. The third line contains an integer (q), the number of queries. Each of the next (q) lines contains two integers (l) and (r) (1-indexed) describing a query.

outputFormat

For each query, print a single integer on a new line representing the number of unique side lengths in the specified range.## sample

5
4 5 6 4 7
1
1 3
3

</p>