#include <bits/stdc++.h>
using namespace std;
int arr[4000];
double dp[10000000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (arr[i] > arr[j]) ++cnt;
  dp[0] = 0.0;
  dp[1] = 1.0;
  for (int i = 2; i <= cnt; ++i) dp[i] = dp[i - 2] + 4.0;
  printf("%f\n", dp[cnt]);
  return 0;
}
