#include <bits/stdc++.h>
using namespace std;
int ar[7];
int N, K;
map<vector<int>, double> M[5];
int bit[20];
void update(int x) {
  while (x <= N) {
    bit[x] += 1;
    x += (x & -x);
  }
}
int qry(int x) {
  int rs = 0;
  while (x) {
    rs += bit[x];
    x -= (x & -x);
  }
  return rs;
}
int way;
double tot;
double solve(vector<int> v, int pos) {
  if (pos == K) {
    way++;
    memset(bit, 0, sizeof bit);
    double rs = 0;
    for (int i = 0; i < N; i++) {
      rs += qry(N) - qry(v[i]);
      update(v[i] + 1);
    }
    tot += rs;
    return 0;
  }
  int i, j, x, y;
  double res = 0;
  for (i = 0; i < N; i++) {
    for (j = i; j < N; j++) {
      vector<int> tmp = v;
      x = i;
      y = j;
      while (y > x) {
        swap(tmp[x], tmp[y]);
        x++, y--;
      }
      solve(tmp, pos + 1);
    }
  }
  return res;
}
int main() {
  int i, j, k;
  cin >> N >> K;
  vector<int> v;
  for (int i = 0; i < N; i++) {
    cin >> k;
    k--;
    v.push_back(k);
  }
  {
    solve(v, 0);
    double res = tot;
    tot /= (double)way;
    cout << setprecision(13) << fixed;
    cout << tot + 1e-15 << endl;
  }
  return 0;
}
