#include <bits/stdc++.h>
using namespace std;
int a[5000000];
double dp[5000000];
int main() {
  int n, sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j < i; j++) {
      if (a[j] > a[i]) sum++;
    }
  }
  dp[0] = 0;
  for (int i = 2; i <= sum; i += 2) {
    dp[i] = dp[i - 2] + 4;
  }
  if (sum % 2 == 0)
    printf("%lf\n", dp[sum]);
  else
    printf("%lf\n", dp[sum - 1] + 1);
  return 0;
}
