#include <bits/stdc++.h>
using namespace std;
const int N = 103;
const int K_LIMIT = 1100;
int n, k, a[N];
double cur_dp[N][N], prv_dp[N][N], all_cnt;
double c2(int);
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  k = min(K_LIMIT, k);
  all_cnt = c2(n + 1);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (a[j] < a[i])
        cur_dp[i][j] = 1.0;
      else
        cur_dp[j][i] = 1.0;
  for (int t = 0; t < k; t++) {
    swap(cur_dp, prv_dp);
    for (int l = 0; l < n; l++)
      for (int r = 0; r < n; r++) {
        if (l > r) {
          cur_dp[l][r] = 1 - cur_dp[r][l];
          continue;
        } else if (l == r) {
          cur_dp[l][r] = 0;
          continue;
        }
        cur_dp[l][r] = 0;
        for (int i = 0; i <= l; i++) {
          cur_dp[l][r] += prv_dp[i][r] * min(i + 1, r - l);
        }
        for (int i = l + 1; i < r; i++)
          cur_dp[l][r] += prv_dp[i][r] * min(l + 1, r - i);
        for (int j = r; j < n; j++)
          cur_dp[l][r] += prv_dp[l][j] * min(n - j, r - l);
        for (int j = r - 1; j > l; j--)
          cur_dp[l][r] += prv_dp[l][j] * min(n - r, j - l);
        for (int j = 0; j < l; j++)
          cur_dp[l][r] += prv_dp[j + r - l][j] * min(j + 1, n - r);
        for (int i = r + 1; i < n; i++)
          cur_dp[l][r] += prv_dp[i][i - r + l] * min(n - i, l + 1);
        cur_dp[l][r] += prv_dp[r][l] * min(l + 1, n - r);
        double sum = c2(l + 1) + c2(r - l) + c2(n - r);
        cur_dp[l][r] += prv_dp[l][r] * sum;
        cur_dp[l][r] *= 1.0 / all_cnt;
      }
  }
  long double ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) ans += cur_dp[i][j];
  cout << fixed << setprecision(10) << ans << endl;
}
double c2(int k) {
  double x = k;
  return (x * (x - 1)) / 2.0;
}
