#include <bits/stdc++.h>
using namespace std;
inline double c2(const int& n) { return (n * (n + 1)) / 2; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int n, k;
  cin >> n >> k;
  k = min(k, 1000);
  vector<int> p(n + 1);
  for (int i = 1; i <= n; i++) cin >> p[i];
  vector<vector<vector<double> > > dp(
      k + 1, vector<vector<double> >(n + 1, vector<double>(n + 1, 0.)));
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (p[i] > p[j]) dp[0][i][j] = 1.;
  for (int s = 1; s <= k; s++) {
    for (int i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++) {
        dp[s][i][j] += dp[s - 1][i][j] * c2(j - i - 1) / c2(n);
        dp[s][i][j] += dp[s - 1][i][j] * c2(i - 1) / c2(n);
        dp[s][i][j] += dp[s - 1][i][j] * c2(n - j) / c2(n);
        for (int pi = i; pi < j; pi++)
          dp[s][i][j] += dp[s - 1][pi][j] * min(i, j - pi) / c2(n);
        for (int pi = 1; pi < i; pi++)
          dp[s][i][j] += dp[s - 1][pi][j] * min(pi, j - i) / c2(n);
        for (int pj = i + 1; pj <= j; pj++)
          dp[s][i][j] += dp[s - 1][i][pj] * min(pj - i, n - j + 1) / c2(n);
        for (int pj = j + 1; pj <= n; pj++)
          dp[s][i][j] += dp[s - 1][i][pj] * min(j - i, n - pj + 1) / c2(n);
        for (int pi = 1; pi <= i; pi++)
          dp[s][i][j] +=
              (1. - dp[s - 1][pi][pi + j - i]) * min(pi, n - j + 1) / c2(n);
        for (int pj = j + 1; pj <= n; pj++)
          dp[s][i][j] +=
              (1. - dp[s - 1][pj + i - j][pj]) * min(i, n - pj + 1) / c2(n);
      }
  }
  double ans = 0.;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans += dp[k][i][j];
  cout << ans << "\n";
  return 0;
}
