Problem: You are given a permutation of integers from 1 to n. Exactly once you apply the following operation to this permutation: pick a random segment and shuffle its elements. Formally:

  1. Pick a random segment (continuous subsequence) from l to r. All <image> segments are equiprobable. 
  2. Let k = r - l + 1, i.e. the length of the chosen segment. Pick a random permutation of integers from 1 to k, p1, p2, ..., pk. All k! permutation are equiprobable. 
  3. This permutation is applied to elements of the chosen segment, i.e. permutation a1, a2, ..., al - 1, al, al + 1, ..., ar - 1, ar, ar + 1, ..., an is transformed to a1, a2, ..., al - 1, al - 1 + p1, al - 1 + p2, ..., al - 1 + pk - 1, al - 1 + pk, ar + 1, ..., an. 



Inversion if a pair of elements (not necessary neighbouring) with the wrong relative order. In other words, the number of inversion is equal to the number of pairs (i, j) such that i < j and ai > aj. Find the expected number of inversions after we apply exactly one operation mentioned above.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the length of the permutation.

The second line contains n distinct integers from 1 to n — elements of the permutation.

Output

Print one real value — the expected number of inversions. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 9. 

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Example

Input

3
2 3 1


Output

1.916666666666666666666666666667

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
pair<long long, long long> seg[4 * maxn];
void add(long long id, long long L, long long R, long long idx, long long val) {
  if (idx < L || idx >= R) return;
  if (R == L + 1) {
    seg[id].second++;
    seg[id].first += val;
    return;
  }
  long long mid = (L + R) / 2;
  add(2 * id + 0, L, mid, idx, val);
  add(2 * id + 1, mid, R, idx, val);
  seg[id].second = seg[2 * id].second + seg[2 * id + 1].second;
  seg[id].first = seg[2 * id].first + seg[2 * id + 1].first;
}
pair<long long, long long> get(long long id, long long L, long long R,
                               long long l, long long r) {
  if (r <= l || R <= l) return pair<long long, long long>(0, 0);
  if (L >= l && R <= r) return seg[id];
  long long mid = (L + R) / 2;
  pair<long long, long long> P = get(2 * id + 0, L, mid, l, r);
  pair<long long, long long> Q = get(2 * id + 1, mid, R, l, r);
  return pair<long long, long long>(P.first + Q.first, P.second + Q.second);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long double ans = (n + 2) * (n - 1) / 24.0;
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    tmp--;
    pair<long long, long long> P = get(1, 0, n, tmp, n);
    ans += P.second -
           (long double)((n - i) * P.first) / (long double)(n * (n + 1) / 2);
    add(1, 0, n, tmp, i + 1);
  }
  cout << setprecision(30) << ans;
}