#include <bits/stdc++.h>
using namespace std;
vector<int> a;
map<vector<int>, double> mp[10];
double getans(vector<int> a, int rem) {
  int n = a.size(), i, j;
  if (rem == 0) {
    int cnt = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < i; j++) {
        cnt += (a[j] > a[i]);
      }
    }
    return cnt;
  }
  if (mp[rem].count(a) != 0) {
    return mp[rem][a];
  }
  double den = 0, ans = 0;
  for (i = 0; i < n; i++) {
    for (j = i; j < n; j++) {
      reverse(a.begin() + i, a.begin() + j + 1);
      ans += getans(a, rem - 1);
      den++;
      reverse(a.begin() + i, a.begin() + j + 1);
    }
  }
  return mp[rem][a] = ans / den;
}
int main() {
  int i, n, k;
  cin >> n >> k;
  a.resize(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  printf("%.16lf\n", getans(a, k));
  return 0;
}
