You are given an array a of size n. The compressed version of an array is defined as replacing the occurance of consecutive equal integers with the single occurance.
Example: For a=[1,1,2,2,1,1], the compressed version will be [1,2,1].
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 a. Since the sum may be large, print it modulo 109+7.
Example: For a=[3,3,3,3], the subarrays with the compressed numbers are as follows:
Input format
Output format
Print a single integer for each test case denoting the sum of compressed number for all the subarrays of the array a.
Constraints
1≤t≤101≤n≤1051≤a[i]≤105
For test case 1 :
We have a=[6,7,3,6,6].. The subarrays of a with their respective compressed numbers are as follows :
[6] has compressed number 0 as it is already compressed.
Similarly, [6,7],[6,7,3],[6,7,3,6] have compressed number 0 as they are already compressed.
[6,7,3,6,6] has compressed number 2 as we can delete either index 4 or index 5 to get compressed version [6,7,3,6].
[7],[7,3],[7,3,6] have compressed number 0 as they are already compressed.
[7,3,6,6] has compressed number 2.
[3],[3,6] have compressed number 0 as they are already compressed.
[3,6,6] has compressed number 2.
[6] has compressed number 0 as it is already compressed.
[6,6] has compressed number 2.
[6] has compressed number 0 as it is already compressed.
So, total sum of all compressed numbers of all subarrays of a = 8.
For test case 2 :
We have a=[4,4].. The subarrays of a with their respective compressed numbers are as follows :
[4] has compressed number 0 as it is already compressed..
[4,4] has compressed number 2 as we can delete either index 1 or index 2 to get compressed version [4].
So, sum of compressed number = 2.