You are given an array
Example: For
The compressed number of an array is defined as number of ways to remove some non-empty subsequence of indexes from the initial array to make it compressed. Two ways are considered different if the sequence of indexes deleted from the array was different, the order of removing does not matter.
Calculate the sum of compressed number for all subarrays of the array
Example: For
- There are 4 subarrays of type
. The compressed number is 0 as it is already compressed. - There are 3 subarrays of type
. The compressed number is 2 as either of the index can be deleted. So, the sum of compressed number would be 6. - There are 2 subarrays of type
. the compressed number is 3 as either of the sequence of indices or can be deleted. So, the sum of compressed number would be 6. - There is 1 subarray
with the compressed number 4. - So, the sum of compressed number of all subarrays is 16.
Input format
- The first line contains an integer
denoting the number of test cases. - The first line of each test case contains an integer
denoting the size of the array . - The second line of each test case contains
space-separated integers denoting the elements of array .
Output format
Print a single integer for each test case denoting the sum of compressed number for all the subarrays of the array
Constraints
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial