#include <bits/stdc++.h>
using namespace std;
long double dp[9000005];
int a[3005];
int main() {
  int n;
  while (cin >> n) {
    int num = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      for (int j = 0; j < i; ++j)
        if (a[i] < a[j]) num++;
    }
    dp[0] = 0;
    bool f = 0;
    if (num % 2) f = 1;
    int curr = 1;
    while (curr <= num) {
      if (f) {
        dp[curr] = 1 + dp[curr - 1];
      } else {
        dp[curr] = dp[curr - 1] + 3;
      }
      f = !f;
      curr++;
    }
    cout << fixed << setprecision(0) << dp[num] << ".0" << endl;
  }
}
