#include <bits/stdc++.h>
template <class T>
const T& max(const T& a, const T& b) {
  return a > b ? a : b;
}
template <class T>
const T& min(const T& a, const T& b) {
  return a < b ? a : b;
}
using namespace std;
void invers(vector<uint64_t>& s, int from, int to) {
  for (int i(0); i < (to - from + 1) / 2; ++i)
    std::swap(s[from + i], s[to - i]);
}
double find(vector<uint64_t>& s, int depth) {
  if (depth == 0) {
    uint64_t count = 0;
    for (int i(0); i < s.size(); ++i)
      for (int j(i); j < s.size(); ++j) {
        if (s[i] > s[j]) ++count;
      }
    return count;
  }
  uint64_t count = 0;
  double res = 0;
  for (int i(0); i < s.size(); ++i) {
    for (int j(i); j < s.size(); ++j) {
      invers(s, i, j);
      res += find(s, depth - 1);
      count++;
      invers(s, i, j);
    }
  }
  return res / count;
}
int main() {
  uint64_t a(0), b(0), c(0), n(0), m(0), k(0);
  cin >> n >> k;
  vector<uint64_t> s(n, 0);
  for (auto i(0); i < n; ++i) {
    cin >> s[i];
  }
  map<vector<uint64_t>, int> hh;
  cout << std::setprecision(15) << find(s, k) << endl;
  return 0;
}
