Problem Description
Sequence is beautiful and the beauty of an integer sequence is defined as follows: removes all but the first element from every consecutive group of equivalent elements of the sequence (i.e. unique function in C++ STL) and the summation of rest integers is the beauty of the sequence.
Now you are given a sequence of integers . You need find the summation of the beauty of all the sub-sequence of . As the answer may be very large, print it modulo .
Note: In mathematics, a sub-sequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example is a sub-sequence of .
Input
There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:
The first line contains an integer , indicating the size of the sequence. The following line contains integers , denoting the sequence .
The sum of values for all the test cases does not exceed .
Output
For each test case, print the answer modulo
Sample Input
Sample Output
找到递推方法然后就好了。。。