#include <bits/stdc++.h>
using namespace std;
long long mx = -1e9, mn = 1e9 + 5;
long long T, n, m, k, ans, a[5000], b, c, d, l, r, sum, mid, coin, cnt, pos,
    number, x, y, z;
vector<long long> v, v1;
map<long long, long long> mp, mm;
map<long long, long long>::iterator it;
pair<long long, long long> p[100005];
queue<long long> q;
priority_queue<long long> pq;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) cnt++;
    }
  }
  if (cnt == 0) {
    cout << 0;
    return 0;
  }
  cout << cnt * 2 - cnt % 2;
}
