#include <bits/stdc++.h>
using namespace std;
const int maxn = 3E3 + 5;
long long a[maxn], dp[10000000] = {0};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long inversion = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i - 1; j >= 0; --j) {
      if (a[j] > a[i]) inversion++;
    }
  }
  dp[0] = 0;
  dp[1] = 1;
  for (int i = 0; i <= inversion; ++i) {
    dp[i + 2] = dp[i] + 4;
  }
  cout << dp[inversion] << endl;
}
