#include <bits/stdc++.h>
using namespace std;
int A[4000];
int dp[3000 * 3001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  int s = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - i - 1; j++) {
      if (A[j] > A[j + 1]) {
        swap(A[j], A[j + 1]);
        s++;
      }
    }
  }
  dp[0] = 0;
  dp[1] = 1;
  for (int i = 2; i <= s; i++) {
    dp[i] = dp[i - 2] + 4;
  }
  cout << dp[s] << endl;
}
