#include <bits/stdc++.h>
using namespace std;
int n, p[4096];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  int v = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (p[i] > p[j]) v++;
  printf("%.12f\n", double(v / 2 * 4 + v % 2));
  return 0;
}
