#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 10;
int A[maxn], dp[maxn * maxn], N;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  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++;
    }
  }
  dp[0] = 0;
  dp[1] = 1;
  for (int i = 2; i < inv + 1; i++) dp[i] = 4 + dp[i - 2];
  cout << dp[inv] << '\n';
  return 0;
}
