#include <bits/stdc++.h>
using namespace std;
const signed long long Infinity = 1000000001;
const long double Epsilon = 1e-9;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& V) {
  os << "[";
  for (__typeof(V.begin()) i = V.begin(); i != V.end(); ++i)
    os << *i << (i - V.begin() + 1 == ((int)V.size()) ? "" : ",");
  os << "]\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& S) {
  os << "(";
  for (__typeof(S.begin()) i = S.begin(); i != S.end(); ++i)
    os << *i << (*i == *S.rbegin() ? "" : ",");
  os << ")\n";
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& M) {
  os << "{";
  for (__typeof(M.begin()) i = M.begin(); i != M.end(); ++i)
    os << *i << (i->first == M.rbegin()->first ? "" : ",");
  os << "}\n";
  return os;
}
const int MAXN = 3030;
int N;
int A[MAXN];
long double DP[MAXN];
void read_data() {
  scanf("%d", &N);
  for (int(i) = (1); (i) <= (N); (i)++) scanf("%d", A + i);
}
void solve() {
  int inversions = 0;
  for (int(i) = (1); (i) <= (N); (i)++)
    for (int(j) = (i + 1); (j) <= (N); (j)++)
      if (A[i] > A[j]) ++inversions;
  cout << 2 * inversions - inversions % 2 << ".0000000000000" << endl;
}
int main() {
  read_data();
  solve();
  return 0;
}
