#include <bits/stdc++.h>
using namespace std;
const long long INFll = 1ll * 1000000100 * 1000000100;
const long double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int inv = 0;
  for (int i = 0; i < n; i++) {
    int x = p[i];
    for (int j = i + 1; j < n; j++) {
      if (p[j] < x) inv++;
    }
  }
  long double ans = 0;
  ans = 4 * (inv / 2);
  ans += inv % 2;
  cout.setf(ios::fixed);
  cout << setprecision(20) << ans << endl;
}
