#include <bits/stdc++.h>
using namespace std;
int dp[2][4500005], xl[3005], ans, gd[3005];
void merge(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  merge(l, mid), merge(mid + 1, r);
  int i = l, j = mid + 1, dq = l;
  while (i <= mid && j <= r) {
    if (xl[i] <= xl[j])
      gd[dq++] = xl[i++];
    else
      gd[dq++] = xl[j++], ans += mid - i + 1;
  }
  for (; i <= mid; ++i) gd[dq++] = xl[i];
  for (; j <= r; ++j) gd[dq++] = xl[j];
  for (int i = l; i <= r; ++i) xl[i] = gd[i];
  return;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &xl[i]);
  merge(1, n);
  for (int i = 1; i <= ans; ++i) {
    dp[1][i] = dp[0][i - 1] + 1;
    dp[0][i] = dp[1][i - 1] + 3;
  }
  printf("%.6lf", (double)dp[1][ans]);
}
