#include <bits/stdc++.h>
using namespace std;
long long cnt = 0;
bool mark[33][33][222];
long double dp[33][33][222];
pair<long long, long long> a[10000];
long long p[1111];
pair<long long, long long> fun(long long fi, long long se, long long l,
                               long long r) {
  pair<long long, long long> ret;
  if (fi >= l and fi <= r)
    ret.first = r - (fi - l);
  else
    ret.first = fi;
  if (se >= l and se <= r)
    ret.second = r - (se - l);
  else
    ret.second = se;
  return ret;
}
long double get(long long fi, long long se, long long k) {
  if (k == 0) return 0.0;
  if (mark[fi][se][k]) return dp[fi][se][k];
  long double &ret = dp[fi][se][k];
  ret = 0.0;
  mark[fi][se][k] = true;
  for (long long i = 1; i <= cnt; i++) {
    pair<long long, long long> cur = fun(fi, se, a[i].first, a[i].second);
    if (cur.first > cur.second)
      ret += (1.0 - get(cur.second, cur.first, k - 1)) / (cnt);
    else
      ret += (get(cur.first, cur.second, k - 1)) / (cnt);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++)
    for (long long j = i; j <= n; j++) a[++cnt] = make_pair(i, j);
  for (long long i = 1; i <= n; i++) cin >> p[i];
  long double ans = 0.0;
  for (long long i = 1; i <= n; i++)
    for (long long j = i + 1; j <= n; j++) {
      long double cur = get(i, j, k);
      if (p[i] > p[j]) cur = 1.0 - cur;
      ans += cur;
    }
  cout << fixed << setprecision(10) << ans << endl;
}
