#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int N = 105;
const int K = 100;
int z[N][N][2];
int n, k;
long double count_inv_triv(vector<int> a) {
  int res = 0;
  ;
  int n = a.size();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i > j && a[i] < a[j]) res++;
  return res;
}
vector<int> swapp(vector<int> a, int l, int r) {
  vector<int> b = a;
  for (int i = l; i <= r; i++) b[i] = a[r - (i - l)];
  return b;
}
long double anss;
long double cnt;
void rec(vector<int> tq, int r) {
  if (r == 0) {
    cnt++;
    anss += count_inv_triv(tq);
    return;
  }
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      vector<int> fd = swapp(tq, i, j);
      rec(fd, r - 1);
    }
}
int main() {
  vector<int> mas;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    mas.push_back(temp);
  }
  anss = 0;
  cnt = 0;
  rec(mas, k);
  cout.precision(30);
  cout << fixed << (long double)anss / (long double)cnt;
}
