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