#include <bits/stdc++.h>
using namespace std;
const bool debug = false;
int n, a[3005];
int main() {
  if (!debug) {
    ios_base::sync_with_stdio(false);
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) {
        swap(a[i], a[j]);
        cnt++;
      }
    }
  }
  if (debug) {
    cout << "n = " << n << "\na[] =";
    for (int i = 1; i <= n; i++) {
      cout << " " << a[i];
    }
    cout << "\ncnt = " << cnt << "\n\n";
  }
  if (cnt % 2) {
    cout << cnt * 2 - 1 << ".000000\n";
  } else {
    cout << cnt * 2 << ".000000\n";
  }
  return 0;
}
