#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  int invers = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) invers += (p[i] > p[j]);
  }
  if (invers == 0) {
    cout << "0.0000000" << endl;
  } else {
    vector<double> ans(invers + 1, 0.0);
    ans[1] = 1.0;
    for (int i = 2; i < invers + 1; ++i) {
      ans[i] = 4.0 + ans[i - 2];
    }
    cout.precision(7);
    cout << fixed << ans[invers] << endl;
  }
  return 0;
}
