#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], in;
  in = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[i] < a[j]) in++;
    }
  }
  int ans = in * 2;
  if (in & 1) ans--;
  cout << ans << endl;
}
