#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9;
vector<int> sum;
void add(int pos, int k)
{
for(; pos < sum.size(); pos |= pos + 1)
sum[pos] = (sum[pos] + k) % MOD;
}
int get(int pos)
{
int ret = 0;
for(; pos > 0; pos = (pos & (pos + 1)) - 1)
ret = (ret + sum[pos]) % MOD;
return ret;
}
int main()
{
int n, k;
cin >> n >> k;
vector<int> a(n), b(n, 1);
for(int i = 0; i < n; i++)
cin >> a[i];
for(int i = 0; i < k; i++)
{
sum.assign(n + 1, 0);
for(int j = n - 1; j >= 0; j--)
{
add(a[j], b[j]);
b[j] = get(a[j] - 1);
}
}
cout << get(n);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOTsKCnZlY3RvcjxpbnQ+IHN1bTsKCnZvaWQgYWRkKGludCBwb3MsIGludCBrKQp7CiAgICBmb3IoOyBwb3MgPCBzdW0uc2l6ZSgpOyBwb3MgfD0gcG9zICsgMSkKICAgICAgICBzdW1bcG9zXSA9IChzdW1bcG9zXSArIGspICUgTU9EOwp9CgppbnQgZ2V0KGludCBwb3MpCnsKICAgIGludCByZXQgPSAwOwogICAgZm9yKDsgcG9zID4gMDsgcG9zID0gKHBvcyAmIChwb3MgKyAxKSkgLSAxKQogICAgICAgIHJldCA9IChyZXQgKyBzdW1bcG9zXSkgJSBNT0Q7CiAgICByZXR1cm4gcmV0Owp9CgppbnQgbWFpbigpCnsKICAgIGludCBuLCBrOwogICAgY2luID4+IG4gPj4gazsKICAgIHZlY3RvcjxpbnQ+IGEobiksIGIobiwgMSk7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgICAgIGNpbiA+PiBhW2ldOwogICAgZm9yKGludCBpID0gMDsgaSA8IGs7IGkrKykKICAgIHsKICAgICAgICBzdW0uYXNzaWduKG4gKyAxLCAwKTsKICAgICAgICBmb3IoaW50IGogPSBuIC0gMTsgaiA+PSAwOyBqLS0pCiAgICAgICAgewogICAgICAgICAgICBhZGQoYVtqXSwgYltqXSk7CiAgICAgICAgICAgIGJbal0gPSBnZXQoYVtqXSAtIDEpOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgZ2V0KG4pOwogICAgcmV0dXJuIDA7Cn0=