#include <bits/stdc++.h>
using namespace std;
int powmod(int a, int b) {
  int tmp = 1;
  a %= 1000000009;
  for (; b; b >>= 1) {
    if (b & 1) tmp = (long long)tmp * a % 1000000009;
    a = (long long)a * a % 1000000009;
  }
  return tmp;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void R(int &xx) {
  xx = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
}
inline void R(long long &xx) {
  xx = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
}
int n, a[300011], c;
int main() {
  R(n);
  for (int i = 0; i < n; i++) {
    R(a[i]);
    for (int j = 0; j < i; j++)
      if (a[j] > a[i]) c++;
  }
  printf("%d.000000\n", c * 2 - c % 2);
  return 0;
}
