#include <bits/stdc++.h>
using namespace std;
double dp[3001 * 3001];
int main() {
  long long int i, j, n, inv = 0;
  cout << fixed << setprecision(9);
  cin >> n;
  long long int a[n + 1];
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) inv++;
    }
  }
  dp[0] = 0.0;
  dp[1] = 1.0;
  for (i = 2; i <= inv; i++) dp[i] = dp[i - 2] + 4 * 1.0;
  cout << dp[inv];
  return 0;
}
