#include <bits/stdc++.h>
using namespace std;
int P[35];
int N, K;
double dp[31][31][201];
void work_dp() {
  double total = 2. / (N * (N + 1));
  for (int k = 1; k <= K; k++)
    for (int i = 1; i <= N; ++i) {
      for (int j = i + 1; j <= N; ++j) {
        dp[i][j][k] = 0.0f;
        for (int a = 1; a <= N; a++)
          for (int b = a; b <= N; b++)
            if (b < i || a > j || (a > i && b < j))
              dp[i][j][k] += dp[i][j][k - 1];
            else if (b < j)
              dp[i][j][k] += dp[a + b - i][j][k - 1];
            else if (a > i)
              dp[i][j][k] += dp[i][a + b - j][k - 1];
            else
              dp[i][j][k] += (1 - dp[a + b - j][a + b - i][k - 1]);
        dp[i][j][k] *= total;
      }
    }
}
void print_ans() {
  double ans = 0;
  for (int i = 1; i < N; i++)
    for (int j = i + 1; j <= N; j++)
      ans += (P[i] > P[j] ? dp[i][j][K] : (1 - dp[i][j][K]));
  printf("%.15lf\n", ans);
}
int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; ++i) cin >> P[i];
  for (int i = 1; i < N; ++i)
    for (int j = i + 1; j <= N; ++j) dp[i][j][0] = 1.0f;
  work_dp();
  print_ans();
}
