#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
int a[MAXN];
double dp[MAXN * MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int res = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) res++;
    }
  }
  if (res == 0) {
    printf("0.000000\n");
    return 0;
  }
  if (res == 1) {
    printf("1.000000\n");
    return 0;
  }
  res--;
  dp[0] = 0;
  dp[1] = 3;
  for (int i = 2; i <= res; i++) {
    dp[i] = dp[i - 2] + 4;
  }
  printf("%.6lf\n", dp[res] + 1);
  return 0;
}
