There are N numbers A1,A2,...,An, and you are given Q queries. In each query, you are given two integers l and r.
You are required to print the sum of all the numbers whose frequency of occurrence is between l and r (including l and r). Print a single integer for each query in a new line.
Input format
Output format
For each query, print the sum of all elements of the array whose frequency of occurrence is between l and r (inclusive) in a new line.
Constraints
1≤N≤1000000
1≤Ai≤1000000
1≤Q≤1000000
1≤l≤r≤N
In the first query we need to output the sum of all the numbers whose frequency of occurrecne is between 1 and 4 (inclusive). Here all the given numbers have their frequecny between 1 and 4. 3 occurs 3 times, 4 occurs 2 times, 5, 6, 9 occurs 1 time. So total sum would be 3+3+3+4+4+5+6+9 = 37.