#include <bits/stdc++.h>
using namespace std;
int a[3005];
int ans[10000007];
int main() {
  int n, inv = 0;
  scanf("%d", &n);
  for (long long i = 0; i < n; i++) scanf("%d", &a[i]);
  for (long long i = 0; i < n; i++)
    for (long long j = i + 1; j < n; j++)
      if (a[i] > a[j]) inv++;
  ans[0] = 0;
  for (long long i = 1; i < inv + 1; i++)
    if (i & 1)
      ans[i] = ans[i - 1] + 1;
    else
      ans[i] = ans[i - 1] + 3;
  printf("%.9lf\n", (double)ans[inv]);
  return 0;
}
