#ds302. 区间不同数之和
区间不同数之和
Sum of Distinct Numbers in an Interval
Problem Description
You are given numbers .
There are queries. Each query gives an interval ; compute the sum of the distinct numbers in that interval, i.e. if the same number appears multiple times it is counted only once.
Input Format
The first line contains two integers and ().
The next line contains integers ().
The following lines each contain two integers and ().
Output Format
For each query, output one line containing the answer.
Sample Input
5 5
2 2 3 2 1
1 5
2 3
2 4
1 2
3 5
Sample Output
6
5
5
2
6
Constraints
, , .