#include <bits/stdc++.h>
using namespace std;
double E(int X) {
  if (X == 0) return 0;
  if (X == 1) return 1;
  return 4 + E(X - 2);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  cout << fixed;
  cout << setprecision(6);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int inv = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      if (v[j] > v[i]) ++inv;
    }
  }
  cout << E(inv) << endl;
}
