#include <bits/stdc++.h>
using namespace std;
int a[3001];
int n, k;
int main() {
  cin >> n;
  cout << setprecision(6);
  cout << fixed;
  for (int i = 0; i < n; i++) cin >> a[i];
  k = 0;
  for (int i = 0; i < n; i++)
    for (int j = 1; j < n; j++)
      if (a[j] < a[j - 1]) {
        swap(a[j], a[j - 1]);
        k++;
      }
  if (k == 0) {
    cout << 0.f << endl;
    return 0;
  }
  double e = 1;
  k--;
  if (k % 2 == 0)
    e += k * 2;
  else
    e += (k / 2) * 4 + 3;
  cout << e << endl;
}
