#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long double eps = 1e-16;
const int maxn = 1510;
int n, cnt;
int sum = 0;
void go(int k, vector<int> a) {
  if (k == cnt) {
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (a[i] > a[j]) ++sum;
      }
    }
    return;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      vector<int> na = a;
      reverse(na.begin() + i, na.begin() + j + 1);
      go(k + 1, na);
    }
  }
}
int main() {
  cin >> n >> cnt;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  go(0, a);
  long long d = 1;
  long double res = sum;
  for (int i = 0; i < cnt; ++i) {
    d *= n * (n + 1) / 2;
  }
  res /= d;
  cout.precision(15);
  cout << fixed << res;
  return 0;
}
