Charged Up Array
Practice
3.7 (131 votes)
Arrays
Data structures
Easy
One Dimensional
Problem
43% Success 51825 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

You are given with an array \(A\) of size \(N\).An element \(A_i\) is said to be charged if its value(\(A_i\)) is greater than or equal to \(K_i\). \(K_i\) is the total number of subsets of array \(A\), that consist of element \(A_i\)
Total charge value of the array is defined as summation of all charged elements present in the array mod \(10^9+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 \(A_i\).

OUTPUT FORMAT:

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

CONSTRAINTS:
\(1 \le T \le100\\ 1 \le N \le 10^5\\ 0 \le A_i \le 10^{18}\\\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
62 votes
Tags:
Arrays1-DData Structures
Points:20
90 votes
Tags:
ArraysBrute-force searchData StructuresEasyHash TablesImplementationMathOne-dimensional
Points:20
26 votes
Tags:
ApprovedData StructuresEasyImplementationOne-dimensional