We have an array of N integers and Q queries. In each query, we are given an integer X. For each query, we have to output the number of unordered pairs in array that sum to X.
How can we efficiently answer these sort of queries?
Constraints:
1 <= N <= 2 * 105
1 <= Q <= 2 * 105
1 <= |ai| <= 1018
1 <= X <= 1018