#Lutece1050. Different game
Different game
Migrated from Lutece 1050 Different game
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Alice is playing a new game recently. In this game, there are different kinds of cards. We assume that Alice have pieces of cards for kind.
Alice is asked to divide them into piles and then arrange each pile in one line. After that, Alice will get sequences. For convenience, the sequences are labeled . For each , Alice will get some points, equal to the length of the LCS(longest common subsequence) of and . The total points is the sum of points for all .
Now Alice is wondering the maximum points she can get.
As is known to everyone of you, Bob loves Alice very much. Could you tell Bob the answer to help Bob leave a good impression on Alice.
Input
The first line contains integers and , indicating the number of sequences and the number of different kinds of card.
The second line contains integers , indicating the number of card.
It is guaranteed that .
Output
Print the answer module 1000000007 in one line.
Samples
2 2
2 3
2
Resources
The 13th UESTC Programming Contest Final