#include <bits/stdc++.h>
using namespace std;
const int N = 510;
double dp[N][N];
double A[N][N], B[N][N], C[N][N];
int n, k;
int P[N];
int C2[N];
int main() {
  scanf("%d%d", &n, &k);
  k = min(k, 1000);
  for (int i = 1; i <= n; i++) scanf("%d", &P[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) dp[i][j] = P[i] > P[j];
  for (int i = 1; i <= n; i++) C2[i] = C2[i - 1] + i;
  while (k--) {
    for (int j = 1; j <= n; j++) {
      for (int i = 1; i <= j - 1; i++) A[i][j] = A[i - 1][j] + dp[i][j];
      for (int i = 1; i <= j - 1; i++) A[i][j] += A[i - 1][j];
    }
    for (int i = n; i >= 1; i--) {
      for (int j = n; j >= i + 1; j--) B[i][j] = B[i][j + 1] + dp[i][j];
      for (int j = n; j >= i + 1; j--) B[i][j] += B[i][j + 1];
    }
    for (int j = 0; j <= n - 1; j++) {
      for (int i = 1; i <= n - j; i++) C[i][j] = C[i - 1][j] + dp[i][i + j];
      for (int i = 1; i <= n - j; i++) C[i][j] += C[i - 1][j];
    }
    for (int i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++) {
        dp[i][j] *= C2[i - 1] + C2[j - i - 1] + C2[n - j];
        dp[i][j] += A[j - 1][j] - A[j - i - 1][j] - A[i - 1][j];
        dp[i][j] += B[i][i + 1] - B[i][j + 1] - B[i][n + 2 - j + i];
        dp[i][j] += i * (n + 1 - j);
        dp[i][j] -= C[n + i - j][j - i] - C[n - j][j - i] - C[i - 1][j - i];
        dp[i][j] /= C2[n];
      }
  }
  double ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans += dp[i][j];
  printf("%.10lf\n", ans);
  return 0;
}
