#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
const int maxn = 3005;
int data[maxn];
int main() {
  const int n = Rint();
  for (int i = 0; i < n; ++i) data[i] = Rint();
  int r = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < i; ++j) r += data[j] > data[i];
  if (r == 0)
    puts("0.0000000000000000");
  else if (r == 1)
    puts("1.0000000000000000");
  else {
    if (r == n * (n - 1) / 2) {
      const int t = r - 2;
      const int x = t % 2 == 0 ? t / 2 * 4 : (t - 1) / 2 * 4 + 1;
      printf("%d\n", x + 2);
    } else {
      if (r % 2 == 0)
        printf("%d\n", r / 2 * 4);
      else
        printf("%d\n", (r - 1) / 2 * 4 + 1);
    }
  }
  return 0;
}
