#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e7 + 5;
const long long inf = 1e10;
const long long mod = 1e9 + 7;
long long n;
long long a[maxN];
double f[maxN];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++)
      if (a[i] > a[j]) cnt++;
  }
  f[0] = 0.0;
  f[1] = 1.0;
  for (long long i = 2; i <= cnt + 2; i++) {
    f[i] = f[i - 2] + 4.0;
  }
  printf("%.10f", f[cnt]);
  return 0;
}
