#include <bits/stdc++.h>
using namespace std;
inline void read(long long &x) {
  x = 0;
  long long f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
inline long long Min(long long x, long long y) { return x < y ? x : y; }
inline long long QuickPow(long long x, long long y) {
  long long Res = 1, Temp = x;
  while (y) {
    if (y & 1) Res = Res * Temp % 1000000007;
    Temp = Temp * Temp % 1000000007;
    y /= 2;
  }
  return Res;
}
long long a[3005];
double f[3005 * 3005];
int main() {
  long long n;
  read(n);
  for (register int i = 1; i <= n; ++i) read(a[i]);
  long long Nxd = 0;
  for (register int i = 1; i < n; ++i)
    for (register int j = i + 1; j <= n; ++j)
      if (a[i] > a[j]) Nxd++;
  f[0] = 0;
  f[1] = 1;
  for (register int i = 2; i <= Nxd; ++i) f[i] = 4 + f[i - 2];
  printf("%.10f\n", f[Nxd]);
  return 0;
}
