#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll t[13][111111];
ll n,k,m = 111110;
void upd(int p,int k,int v){
	while(k<=m){
		t[p][k]+=v;
		k|=k+1;
	}
}
ll sum(int p,int r)
{
	ll res = 0;
	while(r>=0){
		res+=t[p][r];
		r = (r&(r+1))-1;
	}
	return res;
}
int main()
{
	cin>>n>>k;
	k++;
	upd(0,0,1);
	ll ans = 0;
	for(int i=0;i<n;i++){
       int v;
       cin>>v;
       for(int j=1;j<=k;j++){
		   ll x = sum(j-1,v-1);
		   upd(j,v,x);
		   if(j == k)ans+=x;
	   }
	}
	cout<<ans;

}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll t[13][111111];
ll n,k,m = 111110;
void upd(int p,int k,ll v){
 while(k<m){
	 t[p][k]+=v;
	 k|=k+1;
 }
}
ll sum(int p,int k)
{
	ll res = 0;
	while(k>=0){
		res+=t[p][k];
		k = (k&(k+1))-1;
	}
	return res;
}
int main()
{
	cin>>n>>k;
	k++;
	upd(0,0,1);
	ll ans = 0;
	for(int i=0;i<n;i++){
       ll v;
       cin>>v;
       for(int j=1;j<=k;j++){
		   ll x = sum(j-1,v-1);
		   upd(j,v,x);
		   if(j == k)ans+=x;
	   }
	}

	cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 1e5 + 5, M = 12;

ll n, a[N], k, fen[N][M], dp[N][M];

ll get(int pos, int j) {
	ll res = 0;
	for (pos++; pos; pos -= pos & (-pos))
		res += fen[pos][j];
	return res;
}

void add(int pos, int j, ll val) {
	for (pos++; pos <= n; pos += pos & (-pos))
		fen[pos][j] += val;
}

int main() {
	cin >> n >> k;
	k++;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		dp[i][1] = 1;
		add(a[i], 1, dp[i][1]);
		for (int j = 2; j <= k; j++) {
			if(a[i] == 0)
				continue;
			dp[i][j] = get(a[i] - 1, j - 1);
			add(a[i], j, dp[i][j]);
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
		ans += dp[i][k];
	cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int N = 100 * 1000 + 5, M = 10 + 4;

ll n, k, seg[N << 2], a[N], ans, c[N][M];

void prep() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= min(M - 1, i); j++) {
			if(i == j || !j)
				c[i][j] = 1;
			else
				c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
		}
	}
}

void add(int pos, int id = 1, int b = 0, int e = n) {
	if(e - b == 1) {
		seg[id]++;
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		add(pos, lc, b, mid);
	else
		add(pos, rc, mid, e);
	seg[id] = seg[lc] + seg[rc];
}

ll get(int l, int r, int id = 1, int b = 0, int e = n) {
	if(l >= e || b >= r)
		return 0;
	if(l <= b && e <= r)
		return seg[id];
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	return get(l, r, lc, b, mid) + get(l, r, rc, mid, e);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	k++;
	prep();
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		ll res = get(0, a[i]);
		res = c[res][k - 1];
		ans += res, add(a[i] - 1);
	}
	cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 100 * 1000 + 5, M = 10 + 5;

ll n, k, a[N], dp[N], seg[N << 2];

void add(int pos, int id = 1, int b = 0, int e = n) {
	if(e - b == 1) {
		seg[id] = 1;
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		add(pos, lc, b, mid);
	else
		add(pos, rc, mid, e);
	seg[id] = seg[lc] + seg[rc];
}

ll get(int l, int r, int id = 1, int b = 0, int e = n) {
	if(l >= e || b >= r)
		return 0;
	if(l <= b && e <= r)
		return seg[id];
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	return get(l, r, lc, b, mid) + get(l, r, rc, mid, e);
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		a[i]--;
		dp[i] = get(0, a[i]);
		add(a[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll res = 1, t = 1;
		for (int j = 0; j < k; j++) {
			res *= (dp[i] - j);
			t *= (j + 1);
		}
		res /= t;
		ans += res;
	}
	cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int N = 100 * 1000 + 5, M = 10 + 4;
const ll mod = 4e18;

ll n, k, seg[N << 2], a[N], ans, c[N][M];

void prep() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= min(M - 1, i); j++) {
			if(i == j || !j)
				c[i][j] = 1;
			else
				c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}
}

void add(int pos, int id = 1, int b = 0, int e = n) {
	if(e - b == 1) {
		seg[id]++;
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		add(pos, lc, b, mid);
	else
		add(pos, rc, mid, e);
	seg[id] = seg[lc] + seg[rc];
}

ll get(int l, int r, int id = 1, int b = 0, int e = n) {
	if(l >= e || b >= r)
		return 0;
	if(l <= b && e <= r)
		return seg[id];
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	return get(l, r, lc, b, mid) + get(l, r, rc, mid, e);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	k++;
	prep();
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		ll res = get(0, a[i]);
		res = c[res][k - 1];
		ans += res, add(a[i] - 1);
	}
	cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int N = 100 * 1000 + 5, M = 10 + 4;

ll n, k, seg[N << 2][M], a[N];

void compress() {
	vector <int> vec;
	for (int i = 0; i < n; i++)
		vec.push_back(a[i]);
	sort(vec.begin(), vec.end());
	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	for (int i = 0; i < n; i++)
		a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
}

void add(int pos, int id = 1, int b = 0, int e = n) {
	if(e - b == 1) {
		seg[id][1]++;
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		add(pos, lc, b, mid);
	else
		add(pos, rc, mid, e);
	seg[id][1] = seg[lc][1] + seg[rc][1];
	for (int i = 2; i <= k; i++) {
		seg[id][i] = seg[lc][i] + seg[rc][i];
		for (int j = 1; j < i; j++)
			seg[id][i] += seg[lc][j] * seg[rc][i - j];
	}
}

int main() {
	cin >> n >> k;
	k++;
	for (int i = 0; i < n; i++)
		cin >> a[i];
//	compress();
	for (int i = 0; i < n; i++)
		add(a[i]);
	cout << seg[1][k] << "\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int N = 100 * 1000 + 5, M = 10 + 4;
const ll mod = 8e18;

ll n, k, seg[N << 2], a[N], ans, c[N][M];

void prep() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= min(M - 1, i); j++) {
			if(i == j || !j)
				c[i][j] = 1;
			else
				c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}
}

void add(int pos, int id = 1, int b = 0, int e = n) {
	if(e - b == 1) {
		seg[id]++;
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		add(pos, lc, b, mid);
	else
		add(pos, rc, mid, e);
	seg[id] = seg[lc] + seg[rc];
}

ll get(int l, int r, int id = 1, int b = 0, int e = n) {
	if(l >= e || b >= r)
		return 0;
	if(l <= b && e <= r)
		return seg[id];
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	return get(l, r, lc, b, mid) + get(l, r, rc, mid, e);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	k++;
	prep();
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		ll res = get(0, a[i]);
		res = c[res][k - 1];
		ans += res, add(a[i] - 1);
	}
	cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 100 * 1000 + 5, M = 10 + 5;

ll n, k, a[N], ans[N][M];

struct node {
	ll dp[M];
	node() {
		memset(dp, 0, sizeof dp);
		dp[0] = 1;
	}
}seg[N << 2];

node merge(node b, node c) {
	node res;
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j <= i; j++) {
			res.dp[i] += b.dp[j] * c.dp[i - j];
		}
	}
	return res;
}

/*

void build(int id = 1, int b = 0, int e = n) {
	seg[id][0] = 1;
	if(e - b == 1)
		return;
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	build(lc, b, mid);
	build(rc, mid, e);
	return;
}
*/

void add(int pos, int id = 1, int b = 0, int e = n) {
	if(e - b == 1) {
		seg[id].dp[1] = 1;
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		add(pos, lc, b, mid);
	else
		add(pos, rc, mid, e);
	seg[id] = merge(seg[lc], seg[rc]);
}

node get(int l, int r, int id = 1, int b = 0, int e = n) {
	if(l >= e || b >= r) {
		node nul;
		return nul;
	}
	if(l <= b && e <= r)
		return seg[id];
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	return merge(get(l, r, lc, b, mid), get(l, r, rc, mid, e));
}

int main() {
	cin >> n >> k;
	k++;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		a[i]--;
		node res = get(0, a[i]);
		for (int j = 0; j < k; j++)
			ans[i][j + 1] = res.dp[j];
		add(a[i]);
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
		res += ans[i][k];
	cout << res << "\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int N = 100 * 1000 + 5, M = 10 + 4;
const ll mod = 8e18;

ll n, k, seg[N << 2], a[N], ans, c[N][M];

void prep() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= min(k - 1, i * 1LL); j++) {
			if(i == j || !j)
				c[i][j] = 1;
			else
				c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}
}

void add(int pos, int id = 1, int b = 0, int e = n) {
	if(e - b == 1) {
		seg[id]++;
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		add(pos, lc, b, mid);
	else
		add(pos, rc, mid, e);
	seg[id] = seg[lc] + seg[rc];
}

ll get(int l, int r, int id = 1, int b = 0, int e = n) {
	if(l >= e || b >= r)
		return 0;
	if(l <= b && e <= r)
		return seg[id];
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	return get(l, r, lc, b, mid) + get(l, r, rc, mid, e);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	k++;
	prep();
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		ll res = get(0, a[i]);
		res = c[res][k - 1];
		ans += res, add(a[i] - 1);
	}
	cout << ans << "\n";
}


#include<bits/stdc++.h>
using namespace std;

#define jadu ios_base::sync_with_stdio(false);
#define rep(i,a,b) for (ll  i = a; i <= b; i++)
#define f first
#define s second
#define lelo(x) scanf("%d",&x);
#define dedo(x) prll f("%d",x);
#define PB push_back
#define MP make_pair
#define sz(c)     (ll )c.size()
typedef long long ll;
typedef vector<ll > vi;
typedef pair<ll ,ll > pi;
const ll  mod = 5000000;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%mod; b/=2; a=(a*a)%mod; } return ans%mod; }

const ll  maxi =100005;
//ll  arr[maxi];
//ll  brr[maxi];
//ll  crr[maxi];
ll  n,m,k,l,j;
ll   BIT[15][1000005];
ll getsum(ll *b,ll idx)
{
	ll  res =0;
	 while(idx>=0){
	     res+= b[idx];
	    // if(res>=mod)  res-=mod;
	     idx = (idx&(idx+1))-1;
	 }
	 return res;
}

void update(ll  *b,ll  idx,ll  val)
{
	while(idx<100000)
	{
		b[idx]+= val;
	//	if(b[idx]>=mod) b[idx]-=mod;
		idx |= idx+1;
	}
}
 main()
{
     cin>>n>>k;
     k++;
	 while(n--){
	 	cin>>m;
	 	update(BIT[1],m,1);
	 //	trace3(BIT[1],m,1);
	 	for(ll  i=2;i<=k;i++){
	 	//	trace3(BIT[i],m,getsum(BIT[i-1],m-1));
	 		update(BIT[i],m,getsum(BIT[i-1],m-1));

		 }
	 }
	 cout<<(getsum(BIT[k],100005));
}


#include<bits/stdc++.h>
using namespace std;

#define jadu ios_base::sync_with_stdio(false);
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define lelo(x) scanf("%d",&x);
#define dedo(x) printf("%d",x);
#define PB push_back
#define MP make_pair
#define sz(c)     (int)c.size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int mod = 1000000007;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%mod; b/=2; a=(a*a)%mod; } return ans%mod; }

const int maxi =100005;
int arr[maxi];
//int brr[maxi];
//int crr[maxi];
ll n,m,k,l,j;
ll dp[15][1000005];

ll getsum(ll idx,ll x){
 ll res =0;
 for(;x>0;x-=x&-x){
 	res += dp[idx][x];

 }
 return res;
}

void update(ll idx,ll x,ll val){
	for(x++;x<=100005;x+= (x&-x)){
		dp[idx][x] += val;
	}
}
int main()
{
	cin>>n>>k;
		k++;

		for(ll i=0;i<n;i++) cin>>arr[i];

		update(1,arr[0],1);

		for(int i=1;i<n;i++){
			ll x= arr[i];
			update(1,x,1);
			for(ll j=1;j<k;j++){
				ll y= getsum(j,x);
				update(j+1,x,y);
			}
		}
	cout<<getsum(k,100005);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define jadu ios_base::sync_with_stdio(false);
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define lelo(x) scanf("%d",&x);
#define dedo(x) printf("%d",x);
#define PB push_back
#define MP make_pair
#define sz(c)     (int)c.size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int mod = 5000000;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%mod; b/=2; a=(a*a)%mod; } return ans%mod; }

const int maxi =100005;
//int arr[maxi];
//int brr[maxi];
//int crr[maxi];
int n,m,k,l,j;
int  BIT[51][100000];
int getsum(int *b,int idx)
{
	int res =0;
	 while(idx>=0){
	     res+= b[idx];
	     if(res>=mod)  res-=mod;
	     idx = (idx&(idx+1))-1;
	 }
	 return res;
}

void update(int *b,int idx,int val)
{
	while(idx<100000)
	{
		b[idx]+= val;
		if(b[idx]>=mod) b[idx]-=mod;
		idx |= idx+1;
	}
}
int main()
{
     cin>>n>>k;
	 while(n--){
	 	cin>>m;
	 	update(BIT[1],m,1);
	 	trace3(BIT[1],m,1);
	 	for(int i=2;i<=k;i++){
	 		trace3(BIT[i],m,getsum(BIT[i-1],m-1));
	 		update(BIT[i],m,getsum(BIT[i-1],m-1));

		 }
	 }
	 cout<<(getsum(BIT[k],99999));
}


#include<bits/stdc++.h>
using namespace std;

#define jadu ios_base::sync_with_stdio(false);
#define rep(i,a,b) for (ll  i = a; i <= b; i++)
#define f first
#define s second
#define lelo(x) scanf("%d",&x);
#define dedo(x) prll f("%d",x);
#define PB push_back
#define MP make_pair
#define sz(c)     (ll )c.size()
typedef long long ll;
typedef vector<ll > vi;
typedef pair<ll ,ll > pi;
const ll  mod = 5000000;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%mod; b/=2; a=(a*a)%mod; } return ans%mod; }

const ll  maxi =100005;
//ll  arr[maxi];
//ll  brr[maxi];
//ll  crr[maxi];
ll  n,m,k,l,j;
ll   BIT[15][1000005];
ll getsum(ll *b,ll idx)
{
	ll  res =0;
	 while(idx>=0){
	     res+= b[idx];
	    // if(res>=mod)  res-=mod;
	     idx = (idx&(idx+1))-1;
	 }
	 return res;
}

void update(ll  *b,ll  idx,ll  val)
{
	while(idx<100006)
	{
		b[idx]+= val;
	//	if(b[idx]>=mod) b[idx]-=mod;
		idx |= idx+1;
	}
}
 main()
{
     cin>>n>>k;
     k++;
	 while(n--){
	 	cin>>m;
	 	update(BIT[1],m,1);
	 //	trace3(BIT[1],m,1);
	 	for(ll  i=2;i<=k;i++){
	 	//	trace3(BIT[i],m,getsum(BIT[i-1],m-1));
	 		update(BIT[i],m,getsum(BIT[i-1],m-1));

		 }
	 }
	 cout<<(getsum(BIT[k],100005));
}


#include<bits/stdc++.h>
using namespace std;

#define jadu ios_base::sync_with_stdio(false);
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define lelo(x) scanf("%d",&x);
#define dedo(x) printf("%d",x);
#define PB push_back
#define MP make_pair
#define sz(c)     (int)c.size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int mod = 5000000;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%mod; b/=2; a=(a*a)%mod; } return ans%mod; }

const int maxi =100005;
//int arr[maxi];
//int brr[maxi];
//int crr[maxi];
int n,m,k,l,j;
int  BIT[51][100000];
int getsum(int *b,int idx)
{
	int res =0;
	 while(idx>=0){
	     res+= b[idx];
	    // if(res>=mod)  res-=mod;
	     idx = (idx&(idx+1))-1;
	 }
	 return res;
}

void update(int *b,int idx,int val)
{
	while(idx<100000)
	{
		b[idx]+= val;
	//	if(b[idx]>=mod) b[idx]-=mod;
		idx |= idx+1;
	}
}
int main()
{
     cin>>n>>k;
     k++;
	 while(n--){
	 	cin>>m;
	 	update(BIT[1],m,1);
	 //	trace3(BIT[1],m,1);
	 	for(int i=2;i<=k;i++){
	 	//	trace3(BIT[i],m,getsum(BIT[i-1],m-1));
	 		update(BIT[i],m,getsum(BIT[i-1],m-1));

		 }
	 }
	 cout<<(getsum(BIT[k],99999));
}


#include<bits/stdc++.h>
using namespace std;

#define jadu ios_base::sync_with_stdio(false);
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define lelo(x) scanf("%d",&x);
#define dedo(x) printf("%d",x);
#define PB push_back
#define MP make_pair
#define sz(c)     (int)c.size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int mod = 5000000;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%mod; b/=2; a=(a*a)%mod; } return ans%mod; }

const int maxi =100005;
//int arr[maxi];
//int brr[maxi];
//int crr[maxi];
int n,m,k,l,j;
int  BIT[51][100000];
int getsum(int *b,int idx)
{
	int res =0;
	 while(idx>=0){
	     res+= b[idx];
	     if(res>=mod)  res-=mod;
	     idx = (idx&(idx+1))-1;
	 }
	 return res;
}

void update(int *b,int idx,int val)
{
	while(idx<100000)
	{
		b[idx]+= val;
		if(b[idx]>=mod) b[idx]-=mod;
		idx |= idx+1;
	}
}
int main()
{
     cin>>n>>k;
     k++;
	 while(n--){
	 	cin>>m;
	 	update(BIT[1],m,1);
	 //	trace3(BIT[1],m,1);
	 	for(int i=2;i<=k;i++){
	 	//	trace3(BIT[i],m,getsum(BIT[i-1],m-1));
	 		update(BIT[i],m,getsum(BIT[i-1],m-1));

		 }
	 }
	 cout<<(getsum(BIT[k],99999));
}


#include<bits/stdc++.h>
using namespace std;

#define jadu ios_base::sync_with_stdio(false);
#define rep(i,a,b) for (ll  i = a; i <= b; i++)
#define f first
#define s second
#define lelo(x) scanf("%d",&x);
#define dedo(x) prll f("%d",x);
#define PB push_back
#define MP make_pair
#define sz(c)     (ll )c.size()
typedef long long ll;
typedef vector<ll > vi;
typedef pair<ll ,ll > pi;
const ll  mod = 5000000;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%mod; b/=2; a=(a*a)%mod; } return ans%mod; }

const ll  maxi =100005;
//ll  arr[maxi];
//ll  brr[maxi];
//ll  crr[maxi];
ll  n,m,k,l,j;
ll   BIT[15][1000005];
ll getsum(ll *b,ll idx)
{
	ll  res =0;
	 while(idx>=0){
	     res+= b[idx];
	    // if(res>=mod)  res-=mod;
	     idx = (idx&(idx+1))-1;
	 }
	 return res;
}

void update(ll  *b,ll  idx,ll  val)
{
	while(idx<100000)
	{
		b[idx]+= val;
	//	if(b[idx]>=mod) b[idx]-=mod;
		idx |= idx+1;
	}
}
 main()
{
     cin>>n>>k;
     k++;
	 while(n--){
	 	cin>>m;
	 	update(BIT[1],m,1);
	 //	trace3(BIT[1],m,1);
	 	for(ll  i=2;i<=k;i++){
	 	//	trace3(BIT[i],m,getsum(BIT[i-1],m-1));
	 		update(BIT[i],m,getsum(BIT[i-1],m-1));

		 }
	 }
	 cout<<(getsum(BIT[k],99999));
}


import java.awt.Point;
import java.awt.geom.Line2D;
import java.io.BufferedReader;
import java.io.File;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.security.GuardedObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.io.InputStream;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        long var=System.currentTimeMillis();
        solver.solve(1, in, out);
        /*if(System.getProperty("ONLINE_JUDGE")==null){
            out.println("["+(double)(System.currentTimeMillis()-var)/1000+"]");
        }*/
        out.close();
    }
}
class Pair {
    long x,y,index;
    Pair(long x,long y,int index){
        this.x=x;
        this.y=y;
        this.index=index;
    }
    public String toString(){
        return this.x+" "+this.y+" ";
    }

}
class tupple{
    long x,y,z;
    ArrayList<String> list=new ArrayList<>();
    tupple(long x,long y,long z){
        this.x=x;
        this.y=y;
        this.z=z;
    }
    tupple(tupple cl){
        this.x=cl.x;
        this.y=cl.y;
        this.z=cl.z;
        this.list=cl.list;
    }
}
class Edge{
    int u;
    int v;
    int time;
    long cost;
    public Edge(int u,int v){
        this.u=u;
        this.v=v;
        time=Integer.MAX_VALUE;
    }
    public int other(int x){
        if(u==x)return v;
        return u;
    }
}
class Ss{
    Integer a[]=new Integer[3];
    Ss(Integer a[]){
        this.a=a;

    }
    public int hashCode(){
        return a[0].hashCode()+a[1].hashCode()+a[2].hashCode();
    }
    public boolean equals(Object o){
        Ss x=(Ss)o;
        for(int i=0;i<3;i++){
            if(x.a[i]!=this.a[i]){
                return false;
            }
        }
        return true;

    }
}
class queary{
    int type;
    int l;
    int r;
    int index;
    queary(int type,int l,int r){
        this.type=type;
        this.l=l;
        this.r=r;
    }
}
class boat implements Comparable<boat>{
    int capacity;
    int index;
    boat(int capacity,int index)
    {
        this.capacity=capacity;
        this.index=index;
    }
    @Override
    public int compareTo(boat o) {
        // TODO Auto-generated method stub
        return this.capacity-o.capacity;
    }
}
class TaskC {
    static long mod=(long)(1e9+7);
/*    SegTree tree;
        int min[];
    static int prime_len=1000000;
    static int prime[]=new int[prime_len];
    static int primes[]=new int[prime_len];
    static int pn=0;
    static{
        //System.out.println("lifhgifwrek");
        for(int i=2;i<prime.length;i++){
            if(prime[i]==0){
                primes[pn++]=i;
            }
            if(1L*i*i<=Math.sqrt(prime.length)){
            for(int j=i*i;j<prime.length;j+=i){
                prime[j]=i;
            }
            }
        }
    //  System.out.println("end");

    //  prime[0]=true;
    //  prime[1]=1;
    }
    /*
     *  long pp[]=new long[10000001];
            pp[0]=0;
            pp[1]=1;
            for(int i=2;i<pp.length;i++){
                if(prime[i]!=0){
                    int gcd=(int)greatestCommonDivisor(i/prime[i], prime[i]);
                    pp[i]=(pp[i/prime[i]]*pp[prime[i]]*gcd)/pp[(int)gcd];
                }
                else
                    pp[i]=i-1;
            }

     * */
            public void solve(int testNumber, FastScanner in, PrintWriter out) throws IOException {
                int n,k;
                n=in.nextInt();
                k=in.nextInt();
                int a[]=new int[n];
                for(int i=0;i<n;i++)
                    a[i]=in.nextInt();
                SegTree tree[]=new SegTree[k+1];
                for(int i=0;i<=k;i++){
                    tree[i]=new SegTree(n+1, new long[2*n+2]);
                }
                for(int i=0;i<n;i++){
                    tree[0].modify(a[i],1L);
                }

                for(int i=1;i<=k;i++){
                    for(int j=n-1;j>=0;j--){
                    //  out.println(Arrays.toString(tree[i-1].t));
                        tree[i].modify(a[j],tree[i-1].query(0, a[j]));
                    //  out.println(a[j]+" "+tree[i].query(a[j], a[j]+1)+" "+tree[i-1].query(0, a[j]));
                        tree[i-1].modify(a[j],0);
                    }
                }
                out.println(tree[k].query(0,n+1));
            }
        BigInteger BMOD=BigInteger.valueOf(mod);
        private long inv(long q) {
            return BigInteger.valueOf(q).modInverse(BMOD).longValue();
        }

            static void dfs(List<Integer>[] graph, boolean[] used, List<Integer> res, int u) {
            used[u] = true;
            for (int v : graph[u])
              if (!used[v])
                dfs(graph, used, res, v);
            res.add(u);
          }

          public static List<Integer> topologicalSort(List<Integer>[] graph) {
            int n = graph.length;
            boolean[] used = new boolean[n];
            List<Integer> res = new ArrayList<>();
            for (int i = n-1; i >0; i--)
              if (!used[i])
                dfs(graph, used, res, i);
            Collections.reverse(res);
            return res;
          }

        public static long[][] mulmatrix(long m1[][],long m2[][],long mod){
            long ans[][]=new long[m1.length][m2[0].length];
            for(int i=0;i<m1.length;i++){
                for(int j=0;j<m2[0].length;j++){
                    for(int k=0;k<m1.length;k++){
                        ans[i][j]+=(m1[i][k]*m2[k][j]);
                        ans[i][j]%=mod;
                    }
                }
            }
            return ans;
        }
        public static long[][] matrixexpo(long m[][],String n,long mod){
            if(n.equals("1")){
                return m.clone();
            }
            if(n.equals("10")){
                return mulmatrix(m, m , mod);
            }
            else{
                long temp [][]=matrixexpo(m,n.substring(0,n.length()-1),mod);
                temp=mulmatrix(temp, temp, mod);
                if(n.charAt(n.length()-1)=='0')return temp;
                else return mulmatrix(temp, m,mod);
            }
        }
        public static boolean isCompatible(long x[],long y[]){

            for(int i=0;i<x.length-1;i++){
                if(x[i]==y[i] && x[i+1]==y[i+1] && x[i]==x[i+1] && y[i]==y[i+1]){
                    return false;
                }
            }
            return true;
        }

        int phi(int n) {
            int res = n;
            for (int i = 2; i * i <= n; ++i) {
                if (n % i == 0) {
                    while (n % i == 0) {
                        n /= i;
                    }
                    res -= res / i;
                }
            }
            if (n != 1) {
                res -= res / n;
            }
            return res;
        }
        long pow(long x,long y,long mod){
            if(y<=0){
                return 1;
            }
            if(y==1){
                return x%mod;
            }
            long temp=pow(x,y/2,mod);
            if(y%2==0){
                return (temp*temp)%mod;
            }
            else{
                return (((temp*temp)%mod)*x)%mod;
            }
        }

/*      long DP(int id,int mask){
            //System.out.println("hi"+dp[id][mask]+" "+id+" "+Integer.toBinaryString(mask));
            if(id==0 && mask==0){
                dp[0][mask]=1;
                return 1;
            }
            else if(id==0){
                dp[0][mask]=0;
                return 0;
            }
            if(dp[id][mask]!=-1){

                return dp[id][mask];
            }
            long ans=0;
            for(int i=0;i<n;i++){
                if((mask & (1<<i))!=0 && c[i][id]>=1){
                        ans+=DP(id-1,mask ^ (1 << i));
                        ans%=mod;
                }
            }
            ans+=DP(id-1,mask);
            ans%=mod;
            dp[id][mask]=ans;
            return ans;
        }*/
            static long greatestCommonDivisor (long m, long n){
                    long x;
                    long y;
                    while(m%n != 0){
                        x = n;
                        y = m%n;
                        m = x;
                        n = y;
                    }
                    return n;
                }
                long no_of_primes(long m,long n,long k){
                    long count=0,i,j;
                    int primes []=new int[(int)(n-m+2)];
                       if(m==1)    primes[0] = 1;
                        for(i=2; i<=Math.sqrt(n); i++)
                        {
                            j = (m/i);    j *= i;
                            if(j<m)
                                j+=i;
                            for(; j<=n; j+=i)
                             {
                                 if(j!=i)
                                    primes[(int)(j-m)] = 1;
                             }
                        }

                for(i=0; i<=n-m; i++)
                            if(primes[(int)i]==0 && (i-1)%k==0)
                                count++;
                return count;
                }
}
class SegTree {
    int n;
    long  t[];
    long mod=(long)(1000000007);
    SegTree(int n,long  t[]){
        this.n=n;
        this.t=t;
        //build();
    }

    void build() {  // build the tree

        for (int i = n - 1; i > 0; --i)
            t[i]=(t[i<<1]+t[i<<1|1]);
    }

     void modify(int p, long value) {  // set value at position p
      for (t[p += n]=value; p > 1; p >>= 1) t[p>>1] = (t[p] + t[p^1]);
    }

     long query(int l, int r) {  // sum on interval [l, r)
      long res=0;

      for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if ((l&1)!=0) res=(res+t[l++]);
            if ((r&1)!=0) res=(res+t[--r]);
          }
      return res;
    }

    //
//
//
}
class FastScanner
{

    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar;
    private int snumChars;
    private SpaceCharFilter filter;

    public FastScanner(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }
    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }

        int res = 0;

        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));

        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }

        long res = 0;

        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));

        return res * sgn;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}
 class UF {

    private int[] parent;  // parent[i] = parent of i
    private byte[] rank;   // rank[i] = rank of subtree rooted at i (never more than 31)
    private int count;     // number of components
    public UF(int N) {
        if (N < 0) throw new IllegalArgumentException();
        count = N;
        parent = new int[N];
        rank = new byte[N];
        for (int i = 0; i < N; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    public int find(int p) {
        if (p < 0 || p >= parent.length) throw new IndexOutOfBoundsException();
        while (p != parent[p]) {
            parent[p] = parent[parent[p]];    // path compression by halving
            p = parent[p];
        }
        return p;
    }
    public int count() {
        return count;
    }

    public boolean connected(int p, int q) {
        return find(p) == find(q);
    }

    public boolean union(int p, int q) {
        int rootP = find(p);
        int rootQ = find(q);
        if (rootP == rootQ) return false;

        // make root of smaller rank point to root of larger rank
        if      (rank[rootP] < rank[rootQ]) parent[rootP] = rootQ;
        else if (rank[rootP] > rank[rootQ]) parent[rootQ] = rootP;
        else {
            parent[rootQ] = rootP;
            rank[rootP]++;
        }
        count--;
        return true;
    }

}


import java.io.*;
import java.util.*;

public class Main implements Runnable
{
    class FenTree
    {
        long[] a = new long[ 100100 ];

        long getSum( int n )
        {
            long res = 0;
            for( ; n >= 0; n = ( n & ( n + 1 ) ) - 1 )
            {
                res += a[ n ];
            }
            return res;
        }

        void add( int n, long value )
        {
            for( ; n < 100100; n = n | ( n + 1 ) )
            {
                a[ n ] += value;
            }
        }
    }

    void solve() throws Exception
    {
        int n = nextInt();
        int k = nextInt();
        FenTree[] dp = new FenTree[ 10 ];
        for( int i = 0; i < 10; i++ ) dp[ i ] = new FenTree();
        long ans = 0;
        for( int i = 0; i < n; i++ )
        {
            int a = nextInt();
            dp[ 0 ].add( a, 1 );
            for( int j = 1; j < k; j++ )
            {
                dp[ j ].add( a, dp[ j - 1 ].getSum( a - 1 ) );
            }
            ans += k == 0 ? 1 : dp[ k - 1 ].getSum( a - 1 );
        }
        out.println( ans );
    }

    public static void main( String[] args )
    {
        new Thread( null, new Main(), "1", ( 1 << 27 ) ).start();
    }

    public void run()
    {
        try
        {
            Locale.setDefault( Locale.US );
            in = new BufferedReader( new InputStreamReader( System.in ) );
            out = new PrintWriter( System.out );
            st = null;
            solve();
        }
        catch( Exception e )
        {
            e.printStackTrace();
            System.exit( 1 );
        }
        finally
        {
            out.close();
        }
    }

    String nextToken() throws IOException
    {
        while( st == null || !st.hasMoreTokens() ) st = new StringTokenizer( in.readLine() );
        return st.nextToken();
    }

    int nextInt() throws IOException
    {
        return Integer.parseInt( nextToken() );
    }

    long nextLong() throws IOException
    {
        return Long.parseLong( nextToken() );
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class C {
	int n,k;
	int a[];
	long dp[][];
	void readInput() throws NumberFormatException, IOException{
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		a = new int[n];
		for(int i=0; i<n; ++i)
			a[i] = sc.nextInt();
	}

	void add(int i, int j, long val){
		while(i<=n){
			dp[i][j] += val;
			i = i + (i&-i);
		}
	}

	long get(int i, int j){
		long res = 0;
		while(i>0){
			res += dp[i][j];
			i = i - (i&-i);
		}
		return res;
	}

	void solve(){
		dp = new long[n+2][k+2];
		for(int i=1; i<=n; i++){
			int x = a[i-1];
			add(x,1,1);
			for(int j=2; j<=k+1; j++){
				long y = get(x-1,j-1);
				add(x,j,y);
			}

		}
		System.out.println(get(n,k+1));

	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		C a = new C();
		a.readInput();
		//a.generateInput();
		a.solve();
	}

	private void generateInput() {
		n = 3;
		k = 3;
		a = new int[n];
		a[0] = 1;
		a[1] = 2;
		a[2] = 3;
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

public class subsequences {

	public static long comp(int n, int r) {

		r = Math.min(r, n - r);
		long ans = 1;

		for (int i = 1; i <= r; i++) {
			ans = ans * ((long) n - (long) i + 1L) / i;
		}
		return ans;
	}

	public static int bit[][];
	public static int n;

	public static void add(int idx, int value, int k) {

		while (idx <= n) {
			bit[idx][k] += value;
			idx += (idx & -idx);
		}
		return;
	}

	public static int get(int idx, int k) {
		int sum = 0;
		while (idx > 0) {
			sum += bit[idx][k];

			idx -= (idx & -idx);
		}
		return sum;
	}

	public static int size[];

	public static void lcs(int a[]) {
		int dp[] = new int[a.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = a[0];
		size[0] = 1;

		for (int i = 1; i < a.length; i++) {
			int bin = Arrays.binarySearch(dp, a[i]);

			if (bin < 0) {
				bin *= -1;
				bin--;
				dp[bin] = a[i];
			}
			size[i] = bin + 1;

		}

		return;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder qq = new StringBuilder();

		String y[] = in.readLine().split(" ");
		n = Integer.parseInt(y[0]);
		int k = Integer.parseInt(y[1]);

		int a[] = new int[n + 1];
		bit = new int[n + 1][k + 2];
		size = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(in.readLine());

		}
		if(k==0)
		{
			System.out.println(n);
			return ;
		}

		// lcs(a);
		long ans = 0;

		for (int i = 0; i < n; i++) {
			add(a[i], 1, 1);
			for (int j = 1; j <= k; j++) {
				int get = get(a[i] - 1, j);
				if (j == k) {
					ans += (long) get;
				}
				add(a[i], get, j + 1);
			}
			// System.out.println("A");
		}
		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

public class subsequences {

	public static long comp(int n, int r) {

		r = Math.min(r, n - r);
		long ans = 1;

		for (int i = 1; i <= r; i++) {
			ans = ans * ((long) n - (long) i + 1L) / i;
		}
		return ans;
	}

	public static int bit[][];
	public static int n;

	public static void add(int idx, int value, int k) {

		while (idx <= n) {
			bit[idx][k] += value;
			idx += (idx & -idx);
		}
		return;
	}

	public static int get(int idx, int k) {
		int sum = 0;
		while (idx > 0) {
			sum += bit[idx][k];

			idx -= (idx & -idx);
		}
		return sum;
	}

	public static int size[];

	public static void lcs(int a[]) {
		int dp[] = new int[a.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = a[0];
		size[0] = 1;

		for (int i = 1; i < a.length; i++) {
			int bin = Arrays.binarySearch(dp, a[i]);

			if (bin < 0) {
				bin *= -1;
				bin--;
				dp[bin] = a[i];
			}
			size[i] = bin + 1;

		}

		return;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder qq = new StringBuilder();

		String y[] = in.readLine().split(" ");
		n = Integer.parseInt(y[0]);
		int k = Integer.parseInt(y[1]);

		int a[] = new int[n + 1];
		bit = new int[n + 1][k + 2];
		size = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(in.readLine());

		}

		// lcs(a);
		long ans = 0;

		for (int i = 0; i < n; i++) {
			add(a[i], 1, 1);
			for (int j = 1; j <= k; j++) {
				int get = get(a[i] - 1, j);
				if (j == k) {
					ans += (long) get;
				}
				add(a[i], get, j + 1);
			}
			// System.out.println("A");
		}
		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class subsequences {

	public static long comp(int n, int r) {

		r = Math.min(r, n - r);
		long ans = 1;

		for (int i = 1; i <= r; i++) {
			ans = ans * ((long) n - (long) i + 1L) / i;
		}
		return ans;
	}

	public static int bit[];
	public static int n;

	public static void add(int idx, int value) {

		while (idx <= n) {
			bit[idx] += value;
			idx += (idx & -idx);
		}
		return;
	}

	public static int get(int idx) {
		int sum = 0;
		while (idx > 0) {
			sum += bit[idx];

			idx -= (idx & -idx);
		}
		return sum;
	}

	public static int size[];

	public static void lcs(int a[]) {
		int dp[] = new int[a.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = a[0];
		size[0] = 1;

		for (int i = 1; i < a.length; i++) {
			int bin = Arrays.binarySearch(dp, a[i]);

			if (bin < 0) {
				bin *= -1;
				bin--;
				dp[bin] = a[i];
			}
			size[i] = bin + 1;

		}

		return;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder qq = new StringBuilder();

		String y[] = in.readLine().split(" ");
		n = Integer.parseInt(y[0]);
		int k = Integer.parseInt(y[1]);

		int a[] = new int[n];
		bit = new int[n + 1];
		size = new int[n];
		long ans = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(in.readLine());
			int get = get(a[i] - 1);
			if(get>=k)
			ans += (long) comp(get, k);
			//System.out.println(ans);
			add(a[i], 1);
		}

		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class a {
	public static class node implements Comparable<node> {
		int x;
		int y;

		node(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(node o) {
			if (o.x < x)
				return 1;
			else if (o.x > x)
				return -1;
			else if (o.y > y)
				return 1;
			else if (o.y < y)
				return -1;
			return 0;
		}

	}

	public static class point {
		int x;
		int y;

		point(int x, int val) {
			this.x = x;
			this.y = val;
		}

	}

	public static BigInteger gcd(BigInteger a, BigInteger b) {
		if (b.equals(BigInteger.ZERO))
			return a;
		return gcd(b, a.mod(b));
	}

	public static long gcd1(long a, long b) {
		if (b == 0)
			return a;
		return gcd1(b, a % b);
	}

	public static ArrayList<Integer> prime;

	public static void sieve(int n) {
		boolean vis[] = new boolean[n + 5];
		vis[1] = true;
		vis[0] = true;
		for (int i = 2; i <= n; i++) {
			if (!vis[i]) {
				prime.add(i);
				for (long j = (long) i * (long) i; j <= n; j += i) {
					vis[(int) j] = true;
				}
			}
		}
	}

	public static int tree[][];
	public static boolean end[][];
	public static int counter;

	public static void trie(String a) {
		int st = 0;

		for (int i = 0; i < a.length(); i++) {
			if (tree[a.charAt(i) - 'a'][st] == 0) {
				tree[a.charAt(i) - 'a'][st] = counter++;
			}

			st = tree[a.charAt(i) - 'a'][st];
		}
		end[a.charAt(a.length() - 1) - 'a'][st] = true;

	}

	public static int seg[][];

	public static int get(int s, int e, int p, int from, int to, int seg[]) {
		if (s >= from && e <= to)
			return seg[p];
		if (s > to || e < from)
			return 0;
		int mid = (s + e) / 2;
		int one = get(s, mid, p * 2, from, to, seg);
		int two = get(mid + 1, e, p * 2 + 1, from, to, seg);
		return Math.max(one, two);
	}

	public static long comp(int n, int r) {
		long ans = 1;
		r = Math.min(r, n - r);
		for (int i = 1; i <= r; i++) {
			ans = ans * ((long) n - (long) i + 1L) / (long) i;
		}
		return ans;
	}

	public static ArrayList<Integer> arr[];
	public static boolean vis[];
	public static Stack<Integer> S;

	public static void bfs(int node) {
		for (int i = 0; i < arr[node].size(); i++) {
			int k = arr[node].get(i);
			if (vis[k] == false) {
				vis[k] = true;
				S.push(k);
				bfs(k);
			}
		}
		S.push(node);
	}

	public static void dfs(int node) {

		for (int i = 0; i < arr[node].size(); i++) {
			int k = arr[node].get(i);
			if (vis[k] == false) {
				vis[k] = true;
				dfs(k);
			}
		}
	}

	public static boolean chPrime(int r) {

		for (int i = 2; i * i <= r; i++) {
			if (r % i == 0)
				return false;
		}
		return true;
	}

	public static int len(long ai) {
		String temp = "" + ai;

		return temp.length();
	}

	public static int f_digit(long ai) {
		String temp = "" + ai;

		return (temp.charAt(0) - '0');

	}

	public static HashMap<Long, Long> dp[];
	public static int block;

	public static long solve(int k, long num, long ai, int bi) {
		if (k == block) {
			if (num == 0) {
				return 1;
			}

			return 0;
		}

		if (dp[k].containsKey(num))
			return dp[k].get(num);

		long a = 0;
		long b;
		for (int i = 0; i < 10; i++) {
			if (k == 0 && i == bi)
				continue;

			b = num + ((long) Math.pow(10, block - k - 1) * (long) i);
			b %= ai;

			a += solve(k + 1, b, ai, bi);
		}
		dp[k].put(num, a);
		return a;
	}

	public static long mo = (long) Math.pow(10, 9) + 7;

	public static long solve(long ai, int len, int bi) {

		long ans = 0;
		HashSet<Long> mp = new HashSet();
		Queue<Long> q = new LinkedList();
		q.add(ai);
		mp.add(ai);

		while (!q.isEmpty()) {

			long e = q.poll();

			int len2 = len(e);

			if (len2 < len) {
				if (bi != 0)
					ans++;
			} else if (len2 == len) {
				if (f_digit(e) != bi)
					ans++;
			}

			for (int i = 0; i < prime.size(); i++) {
				long d = e * (long) prime.get(i);
				if (len(d) > len)
					break;

				if (!mp.contains(d)) {
					mp.add(d);
					q.add(d);
				}
			}

		}

		return ans;
	}

	public static long mod = (long) Math.pow(10, 9) + 7;

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader in = new BufferedReader(new FileReader("cubes.in"));

		StringBuilder qq = new StringBuilder();
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

		// System.out.println(n+" "+m);

		out.close();

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

public class subsequences {

	public static long comp(int n, int r) {

		r = Math.min(r, n - r);
		long ans = 1;

		for (int i = 1; i <= r; i++) {
			ans = ans * ((long) n - (long) i + 1L) / i;
		}
		return ans;
	}

	public static long bit[][];
	public static int n;

	public static void add(int idx, long value, int k) {

		while (idx <= n) {
			bit[idx][k] += value;
			idx += (idx & -idx);
		}
		return;
	}

	public static long get(int idx, int k) {
		long sum = 0;
		while (idx > 0) {
			sum += bit[idx][k];

			idx -= (idx & -idx);
		}
		return sum;
	}

	public static int size[];

	public static void lcs(int a[]) {
		int dp[] = new int[a.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = a[0];
		size[0] = 1;

		for (int i = 1; i < a.length; i++) {
			int bin = Arrays.binarySearch(dp, a[i]);

			if (bin < 0) {
				bin *= -1;
				bin--;
				dp[bin] = a[i];
			}
			size[i] = bin + 1;

		}

		return;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder qq = new StringBuilder();

		String y[] = in.readLine().split(" ");
		n = Integer.parseInt(y[0]);
		int k = Integer.parseInt(y[1]);

		int a[] = new int[n + 1];
		bit = new long[n + 1][k + 2];
		size = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(in.readLine());

		}
		if(k==0)
		{
			System.out.println(n);
			return ;
		}

		// lcs(a);
		long ans = 0;

		for (int i = 0; i < n; i++) {
			add(a[i], 1, 1);
			for (int j = 1; j <= k; j++) {
				long get = get(a[i] - 1, j);
				if (j == k) {
					ans +=  get;
				}
				add(a[i], get, j + 1);
			}
			// System.out.println("A");
		}
		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class subsequences {

	public static long comp(int n, int r) {

		r = Math.min(r, n - r);
		long ans = 1;

		for (int i = 1; i <= r; i++) {
			ans = ans * ((long) n - (long) i + 1L) / i;
		}
		return ans;
	}

	public static int bit[];
	public static int n;

	public static void add(int idx, int value) {

		while (idx <= n) {
			bit[idx] += value;
			idx += (idx & -idx);
		}
		return;
	}

	public static int get(int idx) {
		int sum = 0;
		while (idx > 0) {
			sum += bit[idx];

			idx -= (idx & -idx);
		}
		return sum;
	}

	public static int size[];

	public static void lcs(int a[]) {
		int dp[] = new int[a.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = a[0];
		size[0] = 1;

		for (int i = 1; i < a.length; i++) {
			int bin = Arrays.binarySearch(dp, a[i]);

			if (bin < 0) {
				bin *= -1;
				bin--;
				dp[bin] = a[i];
			}
			size[i] = bin + 1;

		}

		return;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder qq = new StringBuilder();

		String y[] = in.readLine().split(" ");
		n = Integer.parseInt(y[0]);
		int k = Integer.parseInt(y[1]);

		int a[] = new int[n];
		bit = new int[n + 1];
		size = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(in.readLine());
		}

		lcs(a);
		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (size[i] < k + 1)
				add(size[i], 1);
			else {
				int num = get(size[i] - 1);

				ans += (long) comp(num, k);
				add(size[i], 1);

			}
		}
		System.out.println(ans);

	}

}


import java.util.*;
import java.io.*;

public class Main {
    static long[][] dp = new long[12][100005];
    static long n;
    static long k;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextLong();
        k = scan.nextLong();
        for (long ba = 0; ba < n; ba++) {
            long x = scan.nextLong();
            for (long j = 1; j <= k+1; j++) {
                long res;
                if (j == 1) {
                    res = 1;
                } else {
                    res = a(j-1, x-1);
                }
                b(j, x, res);
            }
        }
        System.out.println(a(k+1, n));
    }
    public static void b(long x, long i, long r) {
        while (i <= n) {
            dp[(int) x][(int) i] += r;
            i += i & -i;
        }
        return;
    }
    public static long a(long x, long i) {
        long ans = 0;
        while (i > 0) {
            ans += dp[(int) x][(int) i];
            i -= i & -i;
        }
        return ans;
    }
}


import java.io.*;
import java.util.*;
public final class subs
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static long[][] bit,dp;
	static int n,k;

	static void update(int idx1,int idx2,long val)
	{
		while(idx1<=n)
		{
			bit[idx1][idx2]+=val;
			idx1+=idx1&-idx1;
		}
	}

	static long get(int idx1,int idx2)
	{
		long sum=0;
		while(idx1>0)
		{
			sum=sum+bit[idx1][idx2];
			idx1-=idx1&-idx1;
		}
		return sum;
	}

	public static void main(String args[]) throws Exception
	{
		n=sc.nextInt();k=sc.nextInt();int[] a=new int[n+1];dp=new long[n+1][k+2];bit=new long[n+1][k+2];
		for(int i=1;i<=n;i++)
		{
			a[i]=sc.nextInt();
		}
		dp[1][1]=1;update(a[1],1,1);
		for(int i=2;i<=n;i++)
		{
			update(a[i],1,1);dp[i][1]=1;
			for(int j=2;j<=k+1;j++)
			{
				long curr=get(a[i]-1,j-1);
				dp[i][j]+=curr;
				update(a[i],j,dp[i][j]);
			}
		}
		long res=0;
		for(int i=1;i<=n;i++)
		{
			res=res+dp[i][k+1];
		}
		out.println(res);out.close();
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }

    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

	public String next() throws Exception {
		return nextToken().toString();
	}

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        QuickScanner in = new QuickScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskC {

    public void solve(int testNumber, QuickScanner in, PrintWriter out) {
        int n=in.nextInt();
        int k=in.nextInt();
        int a[]=in.nextInts(n);
        ArrayList<Pair<Integer, Integer>> ev=new ArrayList<Pair<Integer, Integer>>();
        for(int i=0;i<n;i++)
            ev.add(new Pair<Integer, Integer>(a[i], -i));
        Collections.sort(ev);
        SegmentTreeLong dp[]=new SegmentTreeLong[k+1];
        for(int i=0;i<=k;i++)
            dp[i]=new SegmentTreeLong(n+1, new LongMerger()
            {
                public long merge(long a, long b)
                {
                    return a+b;
                }
            },0);

        for(Pair<Integer,Integer> cur: ev)
        {
            long prv=1;
            for(int j=0;j<=k;j++)
            {
                long nxt=dp[j].getF(0, -cur.second);
                dp[j].update(-cur.second, prv);
                prv=nxt;
            }
        }
        out.println(dp[k].getF(0,n));
    }
}

class QuickScanner {
    BufferedReader in;
    StringTokenizer token;
    String delim;
    public QuickScanner(InputStream inputStream)
    {
        this.in=new BufferedReader(new InputStreamReader(inputStream));
        this.delim=" \n\t";
        this.token=new StringTokenizer("",delim);
    }

    public boolean hasNext()
    {
        while(!token.hasMoreTokens())
        {
            try {
                String s=in.readLine();
                if(s==null) return false;
                token=new StringTokenizer(s,delim);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }
        return true;
    }

    public String next()
    {
        hasNext();
        return token.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public int[] nextInts(int n)
    {
        int[] res=new int[n];
        for(int i=0;i<n;i++)
            res[i]=nextInt();
        return res;
    }

}

class Pair<T1 extends Comparable<T1>, T2 extends Comparable<T2> > implements Comparable<Pair<T1,T2> >
{
    public T1 first;
    public T2 second;
    public Pair(T1 first,T2 second)
    {
        this.first=first;
        this.second=second;
    }

    public int compareTo(Pair<T1, T2> pr)
    {
        int v=this.first.compareTo(pr.first);
        if(v==0)
            return this.second.compareTo(pr.second);
        else
            return v;
    }
}

class SegmentTreeLong
{
    int ds;
    int n;
    long tree[];
    long zero;
    LongMerger merger;

    public SegmentTreeLong(int n, LongMerger merger, long zero)
    {
        this.n=n;
        ds=getDS(n);
        tree=new long[2*ds];
        for(int i=0;i<ds;i++)
            tree[i+ds]=zero;
        this.merger=merger;
        this.zero=zero;
        for(int i=ds-1;i>0;i--)
            tree[i]=this.merger.merge(tree[2*i],tree[2*i+1]);
    }

    int getDS(int n)
    {
        n--;
        n|=n>>1;
        n|=n>>2;
        n|=n>>4;
        n|=n>>8;
        n|=n>>16;
        return n+1;
    }
    public void update(int i, long val)
    {
        i+=ds;
        tree[i]=val;
        i>>=1;
        while(i>0)
        {
            tree[i]=merger.merge(tree[2*i],tree[2*i+1]);
            i>>=1;
        }
    }
    public long getF(int l, int r)
    {
        l+=ds;
        r+=ds;
        long lRes=zero;
        long rRes=zero;
        while(l<=r)
        {
            if((l&1)!=0) lRes=merger.merge(lRes,tree[l++]);
            if((r&1)==0) rRes=merger.merge(tree[r--],rRes);
            l>>=1;
            r>>=1;
        }
        return merger.merge(lRes,rRes);
    }
}

interface LongMerger
{
    long merge(long a, long b);
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Gerasimov
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static int k = 0;
    public static HashMap<Integer, Elem> mas = new HashMap<Integer, Elem>();

    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(inp.readLine());
        int n = Integer.parseInt(st.nextToken());
        k = Integer.parseInt(st.nextToken())+1;
        Elem der = new Elem(0, (1 << 17)-1);
        long res = 0;
        for (int i = 0; i < n; i++) {
            int h = Integer.parseInt(inp.readLine());
            long[] omas = der.GetValue(1, h );
            long[] nmas = new long[k + 1];
            for (int j = 1; j < k; j++) {
                nmas[j+1]=omas[j];
            }
            nmas[1]=1;
           // res+=nmas[k];
            mas.get(h).value=nmas;
            mas.get(h).pereschet();

        }

        out.print(der.GetValue(0, n+1)[k]);
        out.close();
    }

    public static class Elem {

        public long[] value = new long[k + 1];
        Elem ch1;
        Elem ch2;
        Elem par;
        int x;
        int y;

        public Elem(int x, int y) {
            this.x = x;
            this.y = y;
            if (x < y) {
                ch1 = new Elem(x, (x + y) / 2);
                ch2 = new Elem((x + y) / 2 + 1, y);
                ch1.par = this;
                ch2.par = this;

            } else {
                mas.put(x, this);
            }
        }

        public long[] F(long[] x, long[] y) {
            long[] res = new long[k + 1];

            for (int i = 0; i <= k; i++) {
                res[i] = x[i] + y[i];
            }
            return res;
        }

        public long[] GetValue(int x, int y) {
            if (x == this.x && y == this.y) {
                return this.value;
            } else {
                return F(
                        (x <= (this.x + this.y) / 2) ? ch1.GetValue(x, Math.min((this.x + this.y) / 2,y)) : new long[k + 1],
                        (y >= (this.x + this.y) / 2 + 1) ? ch2.GetValue(Math.max(x,(this.x + this.y) / 2 + 1), y) : new long[k + 1]
                );

            }
        }

        public void pereschet() {
            if (this.ch1 != null) {
                this.value = F(ch1.value, ch2.value);
            }
            if (this.par != null) {
                this.par.pereschet();
            }
        }

    }

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Gerasimov
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static int k = 0;
    public static HashMap<Integer, Elem> mas = new HashMap<Integer, Elem>();

    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(inp.readLine());
        int n = Integer.parseInt(st.nextToken());
        k = Integer.parseInt(st.nextToken())+1;
        Elem der = new Elem(0, (1 << 18)-1);
        long res = 0;
        for (int i = 0; i < n; i++) {
            int h = Integer.parseInt(inp.readLine());
            long[] omas = der.GetValue(1, h );
            long[] nmas = new long[k + 1];
            for (int j = 1; j < k; j++) {
                nmas[j+1]=omas[j];
            }
            nmas[1]=1;
           // res+=nmas[k];
            mas.get(h).value=nmas;
            mas.get(h).pereschet();

        }

        out.print(der.GetValue(0, n+1)[k]);
        out.close();
    }

    public static class Elem {

        public long[] value = new long[k + 1];
        Elem ch1;
        Elem ch2;
        Elem par;
        int x;
        int y;

        public Elem(int x, int y) {
            this.x = x;
            this.y = y;
            if (x < y) {
                ch1 = new Elem(x, (x + y) / 2);
                ch2 = new Elem((x + y) / 2 + 1, y);
                ch1.par = this;
                ch2.par = this;

            } else {
                mas.put(x, this);
            }
        }

        public long[] F(long[] x, long[] y) {
            long[] res = new long[k + 1];

            for (int i = 0; i <= k; i++) {
                res[i] = x[i] + y[i];
            }
            return res;
        }

        public long[] GetValue(int x, int y) {
            if (x == this.x && y == this.y) {
                return this.value;
            } else {
                return F(
                        (x <= (this.x + this.y) / 2) ? ch1.GetValue(x, Math.min((this.x + this.y) / 2,y)) : new long[k + 1],
                        (y >= (this.x + this.y) / 2 + 1) ? ch2.GetValue(Math.max(x,(this.x + this.y) / 2 + 1), y) : new long[k + 1]
                );

            }
        }

        public void pereschet() {
            if (this.ch1 != null) {
                this.value = F(ch1.value, ch2.value);
            }
            if (this.par != null) {
                this.par.pereschet();
            }
        }

    }

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Gerasimov
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static int k = 0;
    public static HashMap<Integer, Elem> mas = new HashMap<Integer, Elem>();

    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(inp.readLine());
        int n = Integer.parseInt(st.nextToken());
        k = Integer.parseInt(st.nextToken())+1;
        Elem der = new Elem(0, (1 << 3)-1);
        long res = 0;
        for (int i = 0; i < n; i++) {
            int h = Integer.parseInt(inp.readLine());
            long[] omas = der.GetValue(0, h - 1);
            long[] nmas = new long[k + 1];
            for (int j = 1; j < k; j++) {
                nmas[j+1]=omas[j];
            }
            nmas[1]=1;
           // res+=nmas[k];
            mas.get(h).value=nmas;
            mas.get(h).pereschet();

        }

        out.print(der.GetValue(0, n+1)[k]);
        out.close();
    }

    public static class Elem {

        public long[] value = new long[k + 1];
        Elem ch1;
        Elem ch2;
        Elem par;
        int x;
        int y;

        public Elem(int x, int y) {
            this.x = x;
            this.y = y;
            if (x < y) {
                ch1 = new Elem(x, (x + y) / 2);
                ch2 = new Elem((x + y) / 2 + 1, y);
                ch1.par = this;
                ch2.par = this;

            } else {
                mas.put(x, this);
            }
        }

        public long[] F(long[] x, long[] y) {
            long[] res = new long[k + 1];

            for (int i = 0; i <= k; i++) {
                res[i] = x[i] + y[i];
            }
            return res;
        }

        public long[] GetValue(int x, int y) {
            if (x == this.x && y == this.y) {
                return this.value;
            } else {
                return F(
                        (x <= (this.x + this.y) / 2) ? ch1.GetValue(x, (this.x + this.y) / 2) : new long[k + 1],
                        (y >= (this.x + this.y) / 2 + 1) ? ch2.GetValue((this.x + this.y) / 2 + 1, y) : new long[k + 1]
                );

            }
        }

        public void pereschet() {
            if (this.ch1 != null) {
                this.value = F(ch1.value, ch2.value);
            }
            if (this.par != null) {
                this.par.pereschet();
            }
        }

    }

}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 256*1024;

int N, K, S[100010];
int itree[REF*2][16];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    if (K == 0) return N;
    for (int i = 0; i < N; i++) {
        u64 sum = query(S[i], N-1, 0);
        update(S[i]-1, 1, 0);
        update(S[i]-1, N-S[i]-sum, 1);
    }
    for (int k = 2; k <= K; k++) {
        for (int i = 0; i < N; i++) {
            u64 sum = query(S[i], N-1, k-1);
            update(S[i]-1, sum, k);
        }
    }
    return query(0, N-1, K);
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 128*1024;

int N, K, S[100010];
u64 itree[REF*2][16];
u64 dp[16][100010];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) {
        dp[1][i] = 1;
        update(S[i]-1, 1, 1);
        for (int k = 2; k <= K+1; k++) {
            dp[k][i] = query(0, S[i]-2, k-1);
            update(S[i]-1, dp[k][i], k);
        }
    }
    u64 ret = 0;
    for (int i = 0; i < N; i++) ret += dp[K+1][i];
    return ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <memory.h>

using namespace std;

typedef unsigned long long u64;

int N, K, S[100010];

u64 cache[100010][11];
u64 rec(int ind, int k) {
    u64& ret = cache[ind][k];
    if (ret != -1) return ret;
    if (k == 0) return ret = 1;
    if (ind > N) return ret = 0;
    ret = 0;
    for (int i = ind+1; i <= N; i++) {
        if (S[i] > S[ind]) ret += rec(i, k-1);
        ret += rec(i+1, k);
    }
    return ret;
}

u64 solve() {
    memset(cache, -1, sizeof(cache));
    return rec(0, K+1);
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 1; i <= N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    printf("%llu\n", ans);
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 256*1024;

int N, K, S[100010];
int itree[REF*2][16];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) update(i, 1, 0);
    for (int k = 1; k <= K; k++) {
        for (int i = 0; i < N-k; i++) {
            u64 sum = query(S[i], N-1, k-1);
            update(S[i]-1, sum, k);
        }
    }
    return query(0, N-1, K);
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100005;
int n;
inline int lowbit(int x)
{
    return x&-x;
}
void add(LL c[],int pos,LL x)
{
    while(pos<=n)
    {
        c[pos]+=x;
        pos+=lowbit(pos);
    }
}
LL sum(LL c[],int pos)
{
    LL res=0;
    while(pos>0)
    {
        res+=c[pos];
        pos-=lowbit(pos);
    }
    return res;
}
LL c[15][maxn];
int a[maxn];
LL dp[15][maxn];
int main()
{
    int k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        dp[1][i]=1;
        add(c[1],a[i],1);
        for(int j=2;j<=k+1;j++)
        {
            dp[j][i]=sum(c[j-1],a[i]-1);
            add(c[j],a[i],dp[j][i]);
        }
    }
    LL ans=0;
    for(int i=1;i<=n;i++) ans+=dp[k+1][i];
    printf("%lld\n",ans);
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 256*1024;

int N, K, S[100010];
u64 itree[REF*2][16];
u64 dp[16][100010];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) {
        dp[1][i] = 1;
        update(S[i]-1, 1, 1);
        for (int k = 2; k <= K+1; k++) {
            dp[k][i] = query(0, S[i]-2, k-1);
            update(S[i]-1, dp[k][i], k);
        }
    }
    u64 ret = 0;
    for (int i = 0; i < N; i++) ret += dp[K+1][i];
    return ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 256*1024;

int N, K, S[100010];
u64 itree[REF*2][16];
u64 dp[REF*2][16];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) {
        dp[1][i] = 1;
        update(S[i]-1, 1, 1);
        for (int k = 2; k <= K+1; k++) {
            dp[k][i] = query(0, S[i]-2, k-1);
            update(S[i]-1, dp[k][i], k);
        }
    }
    u64 ret = 0;
    for (int i = 0; i < N; i++) ret += dp[K+1][i];
    return ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 128*1024;

int N, K, S[100010];
u64 itree[262144][16];
u64 dp[16][100010];

void update(int p, u64 v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) {
        dp[1][i] = 1;
        update(S[i]-1, 1, 1);
        for (int k = 2; k <= K+1; k++) {
            dp[k][i] = query(0, S[i]-2, k-1);
            update(S[i]-1, dp[k][i], k);
        }
    }
    u64 ret = 0;
    for (int i = 0; i < N; i++) ret += dp[K+1][i];
    return ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef long long u64;

const int REF = 128*1024;

int N, K, S[100010];
u64 itree[262144][16];
u64 dp[16][100010];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) {
        dp[1][i] = 1;
        update(S[i]-1, 1, 1);
        for (int k = 2; k <= K+1; k++) {
            dp[k][i] = query(0, S[i]-2, k-1);
            update(S[i]-1, dp[k][i], k);
        }
    }
    u64 ret = 0;
    for (int i = 0; i < N; i++) ret += dp[K+1][i];
    return ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 128*1024;

int N, K, S[100010];
u64 itree[262144][16];
u64 dp[16][100010];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) {
        dp[1][i] = 1;
        update(S[i]-1, 1, 1);
        for (int k = 2; k <= K+1; k++) {
            dp[k][i] = query(0, S[i]-2, k-1);
            update(S[i]-1, dp[k][i], k);
        }
    }
    u64 ret = 0;
    for (int i = 0; i < N; i++) ret += dp[K+1][i];
    return ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long u64;

const int REF = 128*1024;

int N, K, S[100010];
u64 itree[262144][16];
u64 dp[16][100010];

void update(int p, int v, int k) {
    p += REF;
    itree[p][k] += v;
    while (p) {
        p >>= 1;
        itree[p][k] = itree[p<<1][k]+itree[p<<1|1][k];
    }
}

u64 query(int l, int r, int k) {
    l += REF, r += REF;
    u64 ret = 0;
    while (l <= r) {
        if (l % 2 == 1) ret += itree[l][k];
        if (r % 2 == 0) ret += itree[r][k];
        l = (l+1) >> 1;
        r = (r-1) >> 1;
    }
    return ret;
}

u64 solve() {
    for (int i = 0; i < N; i++) {
        dp[1][i] = 1;
        update(S[i]-1, 1, 1);
        for (int k = 2; k <= K+1; k++) {
            dp[k][i] = query(0, S[i]-2, k-1);
            update(S[i]-1, dp[k][i], k);
        }
    }
    u64 ret = 0;
    for (int i = 0; i < N; i++) ret += dp[K+1][i];
    return ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    printf("%llu\n", ans);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <memory.h>

using namespace std;

typedef unsigned long long u64;

int N, K, S[100010];

u64 cache[100010][15];
u64 rec(int ind, int k) {
    u64& ret = cache[ind][k];
    if (ret != -1) return ret;
    if (k == 0) return ret = 1;
    if (ind > N) return ret = 0;
    ret = 0;
    for (int i = ind+1; i <= N; i++) {
        if (S[i] > S[ind]) ret += rec(i, k-1);
    }
    return ret;
}

u64 solve() {
    memset(cache, -1, sizeof(cache));
    return rec(0, K+1);
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 1; i <= N; i++) scanf("%d", &S[i]);
    u64 ans = solve();
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int NMAX = 1e5 + 7;

const int NMIN = 17;

int n, k, x;
int a[NMAX], dp[NMAX][NMIN]; // dp[i][j] = u prvih i clanova, sa j clanova

struct Tree
{
    long long trrre[4 * NMAX];

    void update(int node, int st, int en, int idx, long long val)
    {
        if(st > en || idx > en || idx < st) return;
        if(st == en)
        {
            trrre[node] = val;
            return;
        }
        int mid = (st + en) / 2;
        update(2 * node, st, mid, idx, val);
        update(2 * node + 1, mid + 1, en, idx, val);
        trrre[node] = trrre[2 * node] + trrre[2 * node + 1];
    }

    long long calc(int node, int st, int en, int l, int r)
    {
        if(l > en || r < st || st > en) return 0;
        if(l <= st && en <= r) return trrre[node];
        int mid = (st + en) / 2;
        return calc(2 * node, st, mid, l, r) + calc(2 * node + 1, mid + 1, en, l, r);
    }

}t[17];

int main()
{
    scanf("%d%d", &n, &k);
    long long ans = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= k + 1; j++)
        {
            if(j == 1)
            {
                t[j].update(1, 1, n, a[i], 1);

            }
            else
            {
                dp[i][j] = t[j-1].calc(1, 1, n, 1, a[i] - 1);
                t[j].update(1, 1, n, a[i], dp[i][j]);
            }
        }
    }
    cout << t[k + 1].calc(1, 1, n, 1, n);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int NMAX = 1e5 + 7;

const int NMIN = 17;

int n, k, x;
int dp[NMAX][NMIN]; // dp[i][j] = u prvih i clanova, sa j clanova

struct Tree
{
    long long trrre[4 * NMAX];

    void update(int node, int st, int en, int idx, long long val)
    {
        if(st > en || idx > en || idx < st) return;
        if(st == en)
        {
            trrre[node] = val;
            return;
        }
        int mid = (st + en) / 2;
        update(2 * node, st, mid, idx, val);
        update(2 * node + 1, mid + 1, en, idx, val);
        trrre[node] = trrre[2 * node] + trrre[2 * node + 1];
    }

    long long calc(int node, int st, int en, int l, int r)
    {
        if(l > en || r < st || st > en) return 0;
        if(l <= st && en <= r) return trrre[node];
        int mid = (st + en) / 2;
        return calc(2 * node, st, mid, l, r) + calc(2 * node + 1, mid + 1, en, l, r);
    }

}t[17];

struct node22
{
    int id;
    long long va;

    bool operator<(const node22 &w)
    {
        if(w.va != va) return va < w.va;
        return id < w.id;
    }

}node[NMAX];

int main()
{
    scanf("%d%d", &n, &k);
    long long ans = 0;
    for(int i = 1; i <= n; i++)
    {
        node[i].id = i;
        scanf("%I64d", &node[i].va);
    }
    sort(node + 1, node + n + 1);
  //  for(int i = 1; i <= n; i++) t[1].update(1, 1, n, i, 1);
    for(int i = 1; i <= n; i++)
    {
        t[1].update(1, 1, n, i, 1);
        for(int j = 2; j <= k + 1; j++)
        {
            dp[i][j] = t[j-1].calc(1, 1, n, 1, node[i].id - 1);
            t[j].update(1, 1, n, node[i].id, dp[i][j]);
        }
    }
    //for(int i = 1; i <= n; i++) ans += dp[i][k + 1];
    cout << t[k + 1].calc(1, 1, n, 1, n);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int NMAX = 1e5 + 7;

const int NMIN = 17;

int n, k, x;
int dp[NMAX][NMIN]; // dp[i][j] = u prvih i clanova, sa j clanova

struct Tree
{
    long long trrre[4 * NMAX];

    void update(int node, int st, int en, int idx, long long val)
    {
        if(st > en || idx > en || idx < st) return;
        if(st == en)
        {
            trrre[node] = val;
            return;
        }
        int mid = (st + en) / 2;
        update(2 * node, st, mid, idx, val);
        update(2 * node + 1, mid + 1, en, idx, val);
        trrre[node] = trrre[2 * node] + trrre[2 * node + 1];
    }

    long long calc(int node, int st, int en, int l, int r)
    {
        if(l > en || r < st || st > en) return 0;
        if(l <= st && en <= r) return trrre[node];
        int mid = (st + en) / 2;
        return calc(2 * node, st, mid, l, r) + calc(2 * node + 1, mid + 1, en, l, r);
    }

}t[17];

struct node22
{
    int id;
    long long va;

    bool operator<(const node22 &w)
    {
        if(w.va != va) return va < w.va;
        return id < w.id;
    }

}node[NMAX];

int main()
{
    scanf("%d%d", &n, &k);
    long long ans = 0;
    for(int i = 1; i <= n; i++)
    {
        node[i].id = i;
        scanf("%I64d", &node[i].va);
    }
    sort(node + 1, node + n + 1);
  //  for(int i = 1; i <= n; i++) t[1].update(1, 1, n, i, 1);
    t[1].update(1, 1, n, 1, 1);
    for(int i = 2; i <= n; i++)
    {
        t[1].update(1, 1, n, i, 1);
        for(int j = 2; j <= k + 1; j++)
        {
            dp[i][j] = t[j-1].calc(1, 1, n, 1, node[i].id - 1);
            t[j].update(1, 1, n, node[i].id, dp[i][j]);
        }
    }
    //for(int i = 1; i <= n; i++) ans += dp[i][k + 1];
    cout << t[k + 1].calc(1, 1, n, 1, n);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int NMAX = 1e5 + 7;

const int NMIN = 17;

int n, k, x;
int a[NMAX]; // dp[i][j] = u prvih i clanova, sa j clanova

struct Tree
{
    long long trrre[4 * NMAX];

    void update(int node, int st, int en, int idx, long long val)
    {
        if(st > en || idx > en || idx < st) return;
        if(st == en)
        {
            trrre[node] = val;
            return;
        }
        int mid = (st + en) / 2;
        update(2 * node, st, mid, idx, val);
        update(2 * node + 1, mid + 1, en, idx, val);
        trrre[node] = trrre[2 * node] + trrre[2 * node + 1];
    }

    long long calc(int node, int st, int en, int l, int r)
    {
        if(l > en || r < st || st > en) return 0;
        if(l <= st && en <= r) return trrre[node];
        int mid = (st + en) / 2;
        return calc(2 * node, st, mid, l, r) + calc(2 * node + 1, mid + 1, en, l, r);
    }

}t[17];

int main()
{
    scanf("%d%d", &n, &k);
    long long ans = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%I64d", &a[i]);
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= k + 1; j++)
        {
            long long tmp;
            if(j == 1)
            {
                t[j].update(1, 1, n, a[i], 1);
                tmp = 1;
            }
            else
            {
                tmp = t[j-1].calc(1, 1, n, 1, a[i] - 1);
                t[j].update(1, 1, n, a[i], tmp);
            }
            if(j == k + 1) ans += tmp;
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int NMAX = 1e5 + 7;

const int NMIN = 17;

int n, k, x;
int a[NMAX]; // dp[i][j] = u prvih i clanova, sa j clanova

struct Tree
{
    long long trrre[4 * NMAX];

    void update(int node, int st, int en, int idx, long long val)
    {
        if(st > en || idx > en || idx < st) return;
        if(st == en)
        {
            trrre[node] = val;
            return;
        }
        int mid = (st + en) / 2;
        update(2 * node, st, mid, idx, val);
        update(2 * node + 1, mid + 1, en, idx, val);
        trrre[node] = trrre[2 * node] + trrre[2 * node + 1];
    }

    long long calc(int node, int st, int en, int l, int r)
    {
        if(l > en || r < st || st > en) return 0;
        if(l <= st && en <= r) return trrre[node];
        int mid = (st + en) / 2;
        return calc(2 * node, st, mid, l, r) + calc(2 * node + 1, mid + 1, en, l, r);
    }

}t[17];

int main()
{
    scanf("%d%d", &n, &k);
    long long ans = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= k + 1; j++)
        {
            long long tmp = 0;
            if(j == 1)
            {
                t[j].update(1, 1, n, a[i], 1);
                tmp = 1;
            }
            else
            {
                tmp = t[j-1].calc(1, 1, n, 1, a[i] - 1);
                t[j].update(1, 1, n, a[i], tmp);
            }
            if(j == k) ans += tmp;
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 200005;

long long int a[N];

long long int c[N];

int  n, s, x;

int main ()

{

    cin.tie(0);

    ios_base :: sync_with_stdio(0);

    cin >> n;

    for ( int i = 1; i <= n; i++ )

    {

    cin >> x;

    a[x] = i;

    }

    for ( int i = 1; i < n; i++ )

    s += abs ( a[i+1] - a[i] );

    cout << s;

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e6;

long long int a[N];

long long int c[N];

long long int  n, s, x;

int main ()

{

    cin.tie(0);

    ios_base :: sync_with_stdio(0);

    cin >> n;

    for ( int i = 1; i <= n; i++ )

    {

    cin >> x;

    a[x] = i;

    }

    for ( int i = 1; i < n; i++ )

    s += abs ( a[i+1] - a[i] );

    cout << s;

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int N = 10000;

long long int a[N];

unsigned long long b[N];

long long int c[N];

int  n, s, x;

int main ()

{

	cin.tie(0);

	ios_base :: sync_with_stdio(0);

	cin >> n;

	for ( int i = 1; i <= n; i++ )

	{

	cin >> x;

	a[x] = i;

    }

	for ( int i = 1; i < n; i++ )

	s += abs ( a[i+1] - a[i] );

	cout << s;

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int N = 10000;

long long int a[N];

unsigned long long b[N];

long long int c[N];

int  n, s, x;

int main ()

{

	cin.tie(0);

	cout.tie(0);

	ios_base :: sync_with_stdio(0);

	cin >> n;

	for ( int i = 1; i <= n; i++ )

	cin >> a[i];

	for ( int i = 1; i < n; i++ )

	s += abs ( a[i+1] - a[i] );

	cout << s;

	return 0;

}


#include <bits/stdc++.h>

using namespace std;
int main() {
	int n; cin >> n;
	vector <pair <int, int> > v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i].first;
		v[i].second = i;
	}
	long long int sum = 0;
	sort(v.begin(), v.end());
	for(int i = 1; i < n; i++) {
		sum += abs(v[i].second - v[i - 1].second);
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n; cin >> n;
	int items[n];
	int last;
	for(int i = 0; i < n; i++) {
		cin >> items[i];
		if(items[i] == 1)
			last = i;
	}

	int sum = 0;
	for(int i = 2; i <= n; i++) {
		for(int j = 0; j < n; j++) {
			if(items[j] == i) {
				sum += abs(j - last);
				last = j;
			}
		}
	}

	cout << sum;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
int main() {
	int n; cin >> n;
	vector <pair <int, int> > v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i].first;
		v[i].second = i;
	}
	int sum = 0;
	sort(v.begin(), v.end());
	for(int i = 1; i < n; i++) {
		sum += abs(v[i].second - v[i - 1].second);
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

int find(int *items, int n, int k) {
	for(int i = 0; i < n; i++)
		if(items[i] == k)
			return i;
}

int main() {
	int n; cin >> n;
	int items[n];
	for(int i = 0; i < n; i++)
		cin >> items[i];
	int count = 1;
	int sum = 0;
	int temp = find(items, n, 1);
	for(int i = 2; i <= n; i++) {
		sum += abs(find(items, n, i) - temp);
		temp = find(items, n, i);
	}

	cout << sum;
	return 0;
}


//----->|try=0; while(!success) try++;|<------
//----->|Belief Yourself,Respect Yourself|<----
//----->|Be Proud Of Yourself,You're Doing Your best|<-----
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
 {
    T r=1;
    while(p) {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
{
    T r=1;
    while(p) {
        if(p&1)r=(r*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return r;
}

//||--------------------------->||Main_Code_Start_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    int n,arr[200001];
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
        {
            cin>>a;
            arr[a]=i;
        }
        //sort(arr,arr+n);
        LL sum=0;
        for(int i=2;i<=n;i++)
        {
            sum+=abs(arr[i]-arr[i-1]);
        }
        cout<<sum<<endl;

    }
}