Under construction

Still being built. Things may change

Distinct Increasing Subsequences of Length K

Time limit2sMemory limit512 MB

Summary
Count the distinct value sequences of length K that appear as increasing subsequences of the given array, modulo 5000000.
Level

Medium7 of 10

Topics
Dynamic programming, Sorting, Combinatorics
Solved
No attempts yet

Problem

You are given a sequence A1,A2,…,ANA_1, A_2, \dots, A_N of length NN and an integer KK. Count the subsequences of AA that have length KK and are increasing. Two subsequences with the same sequence of values count as one, even when they are taken from different positions.

A subsequence is what remains after deleting zero or more elements of AA and keeping the order of the rest. A subsequence B1,B2,…,BKB_1, B_2, \dots, B_K of length KK is increasing when Bi<Bi+1B_i < B_{i+1} holds for every ii with 1≤i<K1 \le i < K.

Input

The first line contains the size NN of the sequence and the integer KK. (1≤N≤1000001 \le N \le 100000, 1≤K≤501 \le K \le 50, K≤NK \le N)

The second line contains A1,A2,…,ANA_1, A_2, \dots, A_N, separated by spaces. (1≤Ai≤1000001 \le A_i \le 100000)

Output

Print, on one line, the number of distinct increasing subsequences of length KK modulo 50000005000000.

Examples2

  1. Example 1

    Input
    4 3
    1 2 2 10
    
    Expected output
    1
    
  2. Example 2

    Input
    5 1
    3 3 1 2 2
    
    Expected output
    3