#include <bits/stdc++.h>
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
using namespace std;
int f[5005];
int main() {
  int n;
  int ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &f[i]);
    for (int j = 1; j < i; j++) {
      if (f[j] > f[i]) ans++;
    }
  }
  if (ans & 1)
    ans = 1 + (ans / 2) * 4;
  else
    ans = ans * 2;
  printf("%.7lf\n", (double)ans);
  return 0;
}
