#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
int a[MAXN];
int n;
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) cin >> a[i];
    int inv = 0;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        if (a[i] > a[j]) inv++;
    int ans = inv * 2;
    if (inv & 1) ans--;
    cout << ans << ".000000" << endl;
  }
  return 0;
}
