#include <bits/stdc++.h>
char ch;
inline void read(int &x) {
  x = 0;
  ch = getchar();
  while ((ch < 48) || (ch > 57)) ch = getchar();
  while ((ch >= 48) && (ch <= 57)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  };
};
int n, i, j, ans, a[3005];
int main() {
  read(n);
  for (i = 1; i <= n; i++) {
    read(a[i]);
    for (j = 1; j < i; j++)
      if (a[j] > a[i]) ++ans;
  };
  if (ans % 2 == 0) {
    ans = ans * 2;
  } else {
    ans = (ans - 1) * 2 + 1;
  };
  printf("%d.000000\n", ans);
}
