You are given with an array A of size N.An element Ai is said to be charged if its value(Ai) is greater than or equal to KiKi is the total number of subsets of array A, that consist of element Ai.
Total charge value of the array is defined as summation of all charged elements present in the array mod 109+7.
Your task is to output the total charge value of the given array A.

INPUT FORMAT:

The first line of input contains number of test cases T.
The first line of each test case consists of N, the size of the array.
Next line contains N space-separated integers corresponding to each element Ai.

OUTPUT FORMAT:

For each test case, output a single number corresponding to total charge value of the given array.



Charged Up Array - HackerEarth Problem Solution


    



Post a Comment

Previous Post Next Post