#include <bits/stdc++.h>
using namespace std;
int orig[10];
int form[10];
bool usado[10][10][5];
int n, k;
double mult = 1;
long long tot = 0;
long long count() {
  tot++;
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    for (int k = i + 1; k <= n; k++)
      if (orig[k] < orig[i]) ret++;
  }
  return ret;
}
long long forma(int passo) {
  long long ret = 0;
  if (passo == k)
    ret = count();
  else {
    for (int i = 1; i <= n; i++)
      for (int k = i; k <= n; k++) {
        if (!usado[i][k][passo]) {
          usado[i][k][passo] = true;
          reverse(orig + i, orig + k + 1);
          ret += forma(passo + 1);
          reverse(orig + i, orig + k + 1);
          usado[i][k][passo] = false;
        }
      }
  }
  return ret;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < (k); i++) mult *= ((n + 1) * n) / (2);
  for (int i = 0; i < (n); i++) cin >> orig[i + 1];
  for (int i = (0); i < (10); i++)
    for (int k = (0); k < (10); k++)
      for (int j = 0; j < (5); j++) usado[i][k][j] = false;
  cout << fixed << setprecision(12) << ((double)forma(0)) / tot;
  return 0;
}
