#include <bits/stdc++.h>
using namespace std;
ifstream fin("A.in");
ofstream fout("A.out");
int n, K, c;
int p[100];
double ans;
void back(int k) {
  if (k == K + 1) {
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= i; ++j) {
        if (p[i] < p[j]) {
          ++cnt;
        }
      }
    }
    ans += 1.0 / c * cnt;
    return;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) {
      for (int k = i, h = j; k < h; ++k, --h) swap(p[k], p[h]);
      back(k + 1);
      for (int k = i, h = j; k < h; ++k, --h) swap(p[k], p[h]);
    }
}
int main() {
  cin >> n >> K;
  c = 1;
  for (int h = 1; h <= K; ++h) c = c * n * (n + 1) / 2;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  back(1);
  cout << fixed << setprecision(10) << ans;
}
