#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 4e18;
const int inf = 2e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int a[3005], pos[3005];
int main(void) {
  int n, i, j, naik = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    pos[a[i]] = i;
  }
  int ans = 0;
  for (i = 1; i <= n; ++i) {
    while (pos[i] > i) {
      swap(a[pos[i]], a[pos[i] - 1]);
      swap(pos[a[pos[i]]], pos[a[pos[i] - 1]]);
      ans++;
    }
  }
  ans = ((ans >> 1) << 2) + (ans & 1);
  printf("%.9f\n", (double)ans);
  return 0;
}
