#include <bits/stdc++.h>
using namespace std;
const int mod = 5e6, maxn = 1e5;
int sum[maxn + 1], a[maxn], b[maxn];
void add(int i, int k)
{
for(; i <= maxn; i += i & -i)
{
sum[i] += k;
if(sum[i] > mod) sum[i] -= mod;
}
}
int get(int i)
{
int ret = 0;
for(; i; i -= i & -i)
{
ret += sum[i];
if(ret > mod) ret -= mod;
}
return ret;
}
int main()
{
int n, k;
cin >> n >> k;
for(int i = 0; i < n; i++)
cin >> a[i], a[i]++, b[i] = 1;
for(int i = 0; i < k; i++)
{
memset(sum, 0, sizeof(sum));
for(int j = 0; j < n; j++)
{
add(a[j], b[j]);
b[j] = get(a[j] - 1);
}
}
cout << get(maxn) << "\n";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IG1vZCA9IDVlNiwgbWF4biA9IDFlNTsKCmludCBzdW1bbWF4biArIDFdLCBhW21heG5dLCBiW21heG5dOwoKdm9pZCBhZGQoaW50IGksIGludCBrKQp7CiAgICBmb3IoOyBpIDw9IG1heG47IGkgKz0gaSAmIC1pKQogICAgewogICAgICAgIHN1bVtpXSArPSBrOwogICAgICAgIGlmKHN1bVtpXSA+IG1vZCkgc3VtW2ldIC09IG1vZDsKICAgIH0KfQoKaW50IGdldChpbnQgaSkKewogICAgaW50IHJldCA9IDA7CiAgICBmb3IoOyBpOyBpIC09IGkgJiAtaSkKICAgIHsKICAgICAgICByZXQgKz0gc3VtW2ldOwogICAgICAgIGlmKHJldCA+IG1vZCkgcmV0IC09IG1vZDsKICAgIH0KICAgIHJldHVybiByZXQ7Cn0KCmludCBtYWluKCkKewogICAgaW50IG4sIGs7CiAgICBjaW4gPj4gbiA+PiBrOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykKICAgICAgICBjaW4gPj4gYVtpXSwgYVtpXSsrLCBiW2ldID0gMTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBrOyBpKyspCiAgICB7CiAgICAgICAgbWVtc2V0KHN1bSwgMCwgc2l6ZW9mKHN1bSkpOwogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBuOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBhZGQoYVtqXSwgYltqXSk7CiAgICAgICAgICAgIGJbal0gPSBnZXQoYVtqXSAtIDEpOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgZ2V0KG1heG4pIDw8ICJcbiI7CiAgICByZXR1cm4gMDsKfQo=