#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
int n;
int a[3010];
int dp[10000000];
int main() {
  while (scanf("%d", &n) != EOF) {
    int i;
    int cnt = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++)
        if (a[i] > a[j]) cnt++;
    }
    if (cnt == 0)
      printf("0.000000\n");
    else {
      dp[0] = 0;
      dp[1] = 1;
      for (i = 2; i <= cnt; i++) {
        dp[i] = 4 + dp[i - 2];
      }
      printf("%lf\n", (double)dp[cnt]);
    }
  }
  return 0;
}
