#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i += 1) {
    cin >> arr[i];
  }
  long long int inv = 0;
  for (long long int i = 0; i < n; i += 1) {
    for (long long int j = i + 1; j < n; j += 1) {
      if (arr[i] > arr[j]) {
        inv++;
      }
    }
  }
  double ans;
  if (inv & 1)
    ans = 2 * inv - 1;
  else
    ans = 2 * inv;
  cout << fixed;
  cout << setprecision(6) << ans << endl;
  return 0;
}
