#include <bits/stdc++.h>
using namespace std;
vector<int> inp;
long long int n, k;
double num = 0;
double invc = 0;
int calcInv(vector<int> &v) {
  int count = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      if (v[i] > v[j]) count++;
    }
  }
  return count;
}
void calc(int k, vector<int> mish) {
  if (k == 1) {
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        vector<int> copy = mish;
        reverse(copy.begin() + i, copy.begin() + j + 1);
        invc += calcInv(copy);
        num++;
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        vector<int> copy = mish;
        reverse(copy.begin() + i, copy.begin() + j + 1);
        calc(k - 1, copy);
      }
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    inp.push_back(temp);
  }
  calc(k, inp);
  printf("%.15f\n", invc / num);
  return 0;
}
