#include <bits/stdc++.h>
using namespace std;
int n, t = 0;
int a[3005];
int l[3005];
int r[3005];
void merge(int lef, int mid, int rig) {
  int n1 = mid - lef + 1;
  int n2 = rig - mid;
  for (int i = 0; i < n1; i++) l[i] = a[lef + i];
  for (int i = 0; i < n2; i++) r[i] = a[mid + i + 1];
  l[n1] = r[n2] = 1000000000;
  for (int i = 0, j = 0, k = lef; k <= rig; k++) {
    if (l[i] <= r[j])
      a[k] = l[i++];
    else
      a[k] = r[j++], t += n1 - i;
  }
}
void merge_sort(int lef, int rig) {
  if (lef == rig) return;
  int mid = (lef + rig) >> 1;
  merge_sort(lef, mid);
  merge_sort(mid + 1, rig);
  merge(lef, mid, rig);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  merge_sort(0, n - 1);
  cout << t * 2 - (t & 1) << ".000000" << endl;
}
