#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MIN;
int a[12345];
double dp[300][40][40];
int main() {
  int n, kk;
  cin >> n >> kk;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (i != j) dp[0][i][j] = (a[i] > a[j]);
  for (int k = 1; k <= kk; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        for (int i1 = 0; i1 < n; ++i1) {
          for (int j1 = i1; j1 < n; ++j1) {
            int newi = i;
            int newj = j;
            if (i1 <= newi && newi <= j1) newi = j1 - (newi - i1);
            if (i1 <= newj && newj <= j1) newj = j1 - (newj - i1);
            dp[k][i][j] += dp[k - 1][newi][newj] * 2. / (n * (n + 1));
          }
        }
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) ans += dp[kk][i][j];
  cout << printf("%.10f", ans);
  return 0;
}
