Processing math: 100%
Value of subsequences - MarisaOJ: Marisa Online Judge

Value of subsequences

Time limit: 1000 ms
Memory limit: 256 MB
The value of an array B is the maximum element in B. Given an array A of n integers. Find the sum of value of all subsequences of length k of A. ### Input - The first line contains 2 integers n,k. - The second line contains n integers Ai. ### Output - Print the sum, modulo 109+7. ### Constraints - 1≤k≤n≤105. ### Example Input: 426765 Output: 39