#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      if (a[j] > a[i]) {
        ++ans;
      }
    }
  }
  printf("%.12f\n", (double)(ans / 2 * 4 + ans % 2));
  return 0;
}
