#include <bits/stdc++.h>
using namespace std;
int n, k;
set<int> invs;
vector<long long> freq(500, 0LL);
map<vector<int>, int> mp;
map<int, vector<int> > rmp;
int countInv(vector<int>& v) {
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (v[i] > v[j]) {
        ret++;
      }
    }
  }
  return ret;
}
void recurse(int perma, int selects) {
  if (selects == k) {
    int inv = countInv(rmp[perma]);
    invs.insert(inv);
    freq[inv]++;
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      vector<int> tempo = rmp[perma];
      reverse(tempo.begin() + i, tempo.begin() + j + 1);
      recurse(mp[tempo], selects + 1);
    }
  }
}
int main(int argc, char const* argv[]) {
  scanf("%d%d", &n, &k);
  vector<int> perm(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &perm[i]);
  }
  vector<int> temp(n);
  for (int i = 0; i < n; i++) {
    temp[i] = i + 1;
  }
  int cntr = 0;
  do {
    mp[temp] = cntr;
    rmp[cntr++] = temp;
  } while (next_permutation(temp.begin(), temp.end()));
  recurse(mp[perm], 0);
  set<int>::iterator it;
  long long sum = 0;
  for (it = invs.begin(); it != invs.end(); it++) {
    sum += freq[*it] * 1LL;
  }
  double ansa = 0.0;
  for (it = invs.begin(); it != invs.end(); it++) {
    ansa += freq[*it] * (*it) * 1LL;
  }
  ansa = ansa / (double)sum;
  printf("%.15lf", ansa);
  return 0;
}
