#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265359;
const double EPS = 1e-6;
const int INF = (2e9);
const long long P = 1e9 + 7;
vector<int> nums;
long long n;
double memo[3000 * 3000][2];
bool visited[3000 * 3000][2];
double dp(long long i, int turn) {
  if (i == 0) return 0;
  if (i == 1) {
    if (!turn)
      return 1.0;
    else
      return 1.5 / 0.5;
  }
  if (visited[i][turn]) return memo[i][turn];
  double res;
  if (turn == 0) {
    res = (1.0 + dp(i - 1, !turn));
  } else {
    res = (1.0 + 0.5 * (1.0 + dp(i - 1, 0))) / 0.5;
  }
  visited[i][turn] = 1;
  return memo[i][turn] = res;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  nums.resize(n);
  int invs = 0;
  for (int i = 0; i < n; i++) cin >> nums[i];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (nums[j] < nums[i]) invs++;
    }
  }
  memo[0][0] = 0;
  memo[0][1] = 0;
  memo[1][0] = 1.0;
  memo[1][1] = 1.5 / 0.5;
  for (int i = 2; i <= invs; i++) {
    for (int j = 0; j < 2; j++) {
      if (j == 0) {
        memo[i][j] = (1.0 + memo[i - 1][1]);
      } else {
        memo[i][j] = (1.0 + 0.5 * (1.0 + memo[i - 1][0])) / 0.5;
      }
    }
  }
  if (invs == 0) {
    cout << setprecision(12) << fixed << 0.0 << endl;
  } else {
    cout << setprecision(12) << fixed << memo[invs][0] << endl;
  }
  return 0;
}
