#include <bits/stdc++.h>
const int maxn = 3000 + 10;
int n;
struct Tnode {
  double a, b;
} f[maxn], tmp;
int data[maxn];
int tot;
int main() {
  scanf("%d", &n);
  data[0] = 0;
  tot = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &data[i]);
  }
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      if (data[i] > data[j]) tot++;
  printf("%d.000000\n", tot / 2 * 4 + (tot & 1));
  return 0;
}
