#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 nn different kinds of cards. We assume that Alice have cic_i pieces of cards for ithi_{th} kind.

Alice is asked to divide them into mm piles and then arrange each pile in one line. After that, Alice will get mm sequences. For convenience, the sequences are labeled S1,S2,,SmS_1, S_2, \cdots , S_m. For each i<ji < j, Alice will get some points, equal to the length of the LCS(longest common subsequence) of SiS_i and SjS_j. The total points is the sum of points for all i<ji < j.

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 22 integers mm and nn, indicating the number of sequences and the number of different kinds of card.

The second line contains nn integers cic_i, indicating the number of ithi_{th} card.

It is guaranteed that 1n,m100000,0ci1000001 \leq n, m \leq 100000, 0 \leq c_i \leq 100000.

Output

Print the answer module 1000000007 in one line.

Samples

2 2
2 3
2

Resources

The 13th UESTC Programming Contest Final