#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int a[3003];
double f[3003 * 3003];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) scanf("%d", &a[i]);
  int cnt = 0;
  for (int i = 1; i < n + 1; i++) {
    for (int j = i + 1; j < n + 1; j++) {
      if (a[i] > a[j]) cnt++;
    }
  }
  f[0] = 0;
  f[1] = 1;
  for (int i = 2; i < cnt + 1; i++) f[i] = f[i - 2] + 4;
  printf("%.6f", f[cnt]);
  return 0;
}
