#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, N = 4010, P = 1e9 + 7;
template <class T>
inline bool chkmin(T &A, T B) {
  return B < A ? A = B, 1 : 0;
}
template <class T>
inline bool chkmax(T &A, T B) {
  return A < B ? A = B, 1 : 0;
}
template <class T>
inline void Add(T &first, T second) {
  first += second;
  if (first >= P) first -= P;
  if (first < 0) first += P;
}
int n, A[N], cnt;
int main() {
  cin >> n;
  for (int i = (1), i_end = (n); i <= i_end; ++i) cin >> A[i];
  for (int i = (1), i_end = (n); i <= i_end; ++i)
    for (int j = (i + 1), j_end = (n); j <= j_end; ++j) cnt += A[i] > A[j];
  cout << cnt * 2 - (cnt & 1);
  return 0;
}
