#P6725. [COCI 2015/2016 #5] PERICA

[COCI 2015/2016 #5] PERICA

Description

Given a sequence of length NN, a1,a2,,aNa_1, a_2, \dots, a_N.

Please compute the sum of the maximum value over all combinations of KK numbers, modulo 109+710^9 + 7.

Input Format

The first line contains two integers N,KN, K.

The second line contains a sequence of length NN: a1,a2,,aNa_1, a_2, \dots, a_N.

Output Format

Output one integer on one line: the sum of the maximum value over all combinations of KK numbers, modulo 109+710^9 + 7.

5 3
2 4 2 3 4
39
5 1
1 0 1 1 1
4
5 2
3 3 4 0 0
31

Hint

Sample Explanation

Sample 11

All combinations of KK numbers are: $[2, 4, 2], [2, 4, 3], [2, 4, 4], [2, 2, 3], [2, 2, 4], [2, 3, 4], [4, 2, 3], [4, 2, 4], [4, 3, 4], [2, 3, 4]$.

Constraints

For 40%40\% of the testdata, N103N \le 10^3.
For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 1K501 \le K \le 50.

Notes

Translated from COCI2015-2016 CONTEST #5 T3 PERICA

Translated by ChatGPT 5