#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
int n;
int a[MAXN];
double p[MAXN * MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int m = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      if (a[i] < a[j]) m++;
  p[0] = 0.0;
  for (int i = 1; i <= m; i++) {
    if (i & 1)
      p[i] = p[i - 1] + 1.0;
    else
      p[i] = p[i - 1] + 3.0;
  }
  printf("%.12f\n", p[m]);
  return 0;
}
