#include <bits/stdc++.h>
using namespace std;
inline double f(int n) { return n * (n + 1) / 2; }
bool eq(double n, double m) { return n + 1e-5 > m && n - 1e-5 < m; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  double P = 1. / f(n);
  vector<int> V(n);
  for (auto& x : V) cin >> x;
  vector<vector<vector<double>>> DP(
      k + 1, vector<vector<double>>(n, vector<double>(n, 0)));
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      int num = 0;
      for (int k = i; k <= j; k++)
        for (int l = k + 1; l <= j; l++) num += V[k] > V[l];
      DP[0][i][j] = num;
    }
  for (int s = 1; s <= k; s++)
    for (int l = 0; l < n; l++)
      for (int r = l; r < n; r++)
        for (int i = 0; i < n; i++)
          for (int j = i + 1; j < n; j++) {
            if (j < l || i > r)
              DP[s][i][j] += DP[s - 1][i][j] * P;
            else if (i <= l && r <= j)
              DP[s][i][j] +=
                  (DP[s - 1][i][j] + f(r - l) - DP[s - 1][l][r] * 2) * P;
            else if (l <= i && j <= r)
              DP[s][i][j] += (f(j - i) - DP[s - 1][l + r - j][r + l - i]) * P;
            else if (i >= l)
              DP[s][i][j] +=
                  (DP[s - 1][r + 1][j] + f(r - i) - DP[s - 1][l][l + r - i] +
                   DP[s - 1][l][j] - DP[s - 1][l + r - i + 1][j] -
                   DP[s - 1][l][r] + DP[s - 1][l + r - i + 1][r]) *
                  P;
            else
              DP[s][i][j] +=
                  (DP[s - 1][i][l - 1] + f(j - l) - DP[s - 1][r + l - j][r] +
                   DP[s - 1][i][r] - DP[s - 1][i][r + l - j - 1] -
                   DP[s - 1][l][r] + DP[s - 1][l][r + l - j - 1]) *
                  P;
          }
  cout << setprecision(20) << DP[k][0][n - 1];
  return 0;
}
