#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T GCD(T a, T b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
template <typename T>
inline T SQR(T a) {
  return a * a;
}
template <typename T>
inline long long BigMod(T a, T b, T m) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return SQR(BigMod(a, b / 2, m)) % m;
  else
    return (a % m * BigMod(a, b - 1, m)) % m;
}
int main() {
  int tc, cs;
  int i, j, k;
  int n;
  int arr[3005];
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  int sp = 0;
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (arr[i] > arr[j]) sp++;
    }
  }
  if (sp % 2)
    cout << 2 * sp - 1 << ".000000" << endl;
  else
    cout << 2 * sp << ".000000" << endl;
  return 0;
}
