#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int n, a[N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int inv = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (a[i] > a[j]) ++inv;
  if (inv % 2)
    inv = 1 + (inv / 2) * 4;
  else
    inv *= 2;
  cout << fixed << setprecision(6) << double(inv) << '\n';
}
