#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
int p[3005];
int n, cnt;
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
  }
  cnt = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (p[j] < p[i]) {
        ++cnt;
      }
    }
  }
  printf("%.9f\n", (double)cnt + cnt / 2 * 2);
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
