#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool elem(set<T> st, T val) {
  return (st.find(val) != st.end());
}
int a[10000];
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < (int)n; ++i) cin >> a[i + 1];
  int inv = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (a[i] > a[j]) inv++;
    }
  }
  if (inv % 2 == 0)
    printf("%lf\n", 2.0 * inv);
  else
    printf("%lf\n", 2.0 * inv - 1.0);
  return 0;
}
