#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
const int MOD = 1e9, maxn = 1e5;
vector<int> sum;
void merge_sort(vector<pair<int, int> > &to_sort, vector<int> &inv, vector<int> &res, int l, int r)
{
if(r - l == 1)
return;
int m = (l + r) / 2;
merge_sort(to_sort, inv, res, l, m);
merge_sort(to_sort, inv, res, m, r);
vector<pair<int, int> > tmp;
tmp.reserve(r - l + 1);
int it1 = l, it2 = m;
int cnt = 0;
while(it1 < m || it2 < r)
{
if(it2 == r || (it1 != m && to_sort[it1] < to_sort[it2]))
{
tmp.push_back(to_sort[it1]);
cnt += inv[to_sort[it1].y];
if(cnt > MOD) cnt -= MOD;
it1++;
}
else
{
tmp.push_back(to_sort[it2]);
res[to_sort[it2].y] += cnt;
if(res[to_sort[it2].y] > MOD) res[to_sort[it2].y] -= MOD;
it2++;
}
}
for(int i = l; i < r; i++)
to_sort[i] = tmp[i - l];
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<pair<int, int> > a(n);
vector<int> b(maxn + 1, 1);
for(int i = 0; i < n; i++)
cin >> a[i].x, a[i].y = i;
reverse(a.begin(), a.end());
for(int i = 0; i < n; i++) a[i].y = i;
for(int i = 1; i < k; i++)
{
vector<pair<int, int> > ta(a);
vector<int> tb(maxn + 1, 0);
merge_sort(ta, b, tb, 0, n);
b = tb;
}
int cnt = 0;
for(int i = 0; i < n; i++)
{
cnt += b[i];
if(cnt > MOD) cnt -= MOD;
}
cout << cnt;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSB4IGZpcnN0CiNkZWZpbmUgeSBzZWNvbmQKCmNvbnN0IGludCBNT0QgPSAxZTksIG1heG4gPSAxZTU7Cgp2ZWN0b3I8aW50PiBzdW07Cgp2b2lkIG1lcmdlX3NvcnQodmVjdG9yPHBhaXI8aW50LCBpbnQ+ID4gJnRvX3NvcnQsIHZlY3RvcjxpbnQ+ICZpbnYsIHZlY3RvcjxpbnQ+ICZyZXMsIGludCBsLCBpbnQgcikKewogICAgaWYociAtIGwgPT0gMSkKICAgICAgICByZXR1cm47CiAgICBpbnQgbSA9IChsICsgcikgLyAyOwogICAgbWVyZ2Vfc29ydCh0b19zb3J0LCBpbnYsIHJlcywgbCwgbSk7CiAgICBtZXJnZV9zb3J0KHRvX3NvcnQsIGludiwgcmVzLCBtLCByKTsKICAgIHZlY3RvcjxwYWlyPGludCwgaW50PiA+IHRtcDsKICAgIHRtcC5yZXNlcnZlKHIgLSBsICsgMSk7CiAgICBpbnQgaXQxID0gbCwgaXQyID0gbTsKICAgIGludCBjbnQgPSAwOwogICAgd2hpbGUoaXQxIDwgbSB8fCBpdDIgPCByKQogICAgewogICAgICAgIGlmKGl0MiA9PSByIHx8IChpdDEgIT0gbSAmJiB0b19zb3J0W2l0MV0gPCB0b19zb3J0W2l0Ml0pKQogICAgICAgIHsKICAgICAgICAgICAgdG1wLnB1c2hfYmFjayh0b19zb3J0W2l0MV0pOwogICAgICAgICAgICBjbnQgKz0gaW52W3RvX3NvcnRbaXQxXS55XTsKICAgICAgICAgICAgaWYoY250ID4gTU9EKSBjbnQgLT0gTU9EOwogICAgICAgICAgICBpdDErKzsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgdG1wLnB1c2hfYmFjayh0b19zb3J0W2l0Ml0pOwogICAgICAgICAgICByZXNbdG9fc29ydFtpdDJdLnldICs9IGNudDsKICAgICAgICAgICAgaWYocmVzW3RvX3NvcnRbaXQyXS55XSA+IE1PRCkgcmVzW3RvX3NvcnRbaXQyXS55XSAtPSBNT0Q7CiAgICAgICAgICAgIGl0MisrOwogICAgICAgIH0KICAgIH0KICAgIGZvcihpbnQgaSA9IGw7IGkgPCByOyBpKyspCiAgICAgICAgdG9fc29ydFtpXSA9IHRtcFtpIC0gbF07Cgp9CgppbnQgbWFpbigpCnsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGludCBuLCBrOwogICAgY2luID4+IG4gPj4gazsKICAgIHZlY3RvcjxwYWlyPGludCwgaW50PiA+IGEobik7CiAgICB2ZWN0b3I8aW50PiBiKG1heG4gKyAxLCAxKTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiAgICAgICAgY2luID4+IGFbaV0ueCwgYVtpXS55ID0gaTsKICAgIHJldmVyc2UoYS5iZWdpbigpLCBhLmVuZCgpKTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspIGFbaV0ueSA9IGk7CiAgICBmb3IoaW50IGkgPSAxOyBpIDwgazsgaSsrKQogICAgewogICAgICAgIHZlY3RvcjxwYWlyPGludCwgaW50PiA+IHRhKGEpOwogICAgICAgIHZlY3RvcjxpbnQ+IHRiKG1heG4gKyAxLCAwKTsKICAgICAgICBtZXJnZV9zb3J0KHRhLCBiLCB0YiwgMCwgbik7CiAgICAgICAgYiA9IHRiOwogICAgfQogICAgaW50IGNudCA9IDA7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgewogICAgICAgIGNudCArPSBiW2ldOwogICAgICAgIGlmKGNudCA+IE1PRCkgY250IC09IE1PRDsKICAgIH0KICAgIGNvdXQgPDwgY250OwogICAgcmV0dXJuIDA7Cn0=