Sequence (Hard)
Time limit1sMemory limit512 MB
Sum the products A[B1]*...*A[BM] over all increasing index tuples B of length M whose chosen values are pairwise distinct, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Sorting
- Solved
- No attempts yet
Problem
You are given a sequence of positive integers and an integer . A sequence is called a good sequence if it satisfies all of the following.
- Its length is .
- Every element is an integer between and .
- It is increasing: .
- are pairwise distinct.
Over all good sequences , find the sum of modulo .
Input
The first line contains the length of the sequence and the length of a good sequence, separated by a space.
The second line contains the sequence , separated by spaces.
Output
Over all good sequences , print the sum of modulo .
Constraints
- ()
- is at most the number of distinct values in .
Hint
The sequence in the sample has two good sequences, and . The required answer is .