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;
char __buf[1 << 18], *__c = __buf, *__ed = __buf;
inline int qr() {
  int ret = 0, f = 0, c = getchar();
  while (!isdigit(c)) f |= c == 45, c = getchar();
  while (isdigit(c)) ret = ret * 10 + c - 48, c = getchar();
  return f ? -ret : ret;
}
const int maxn = 1e5 + 5;
long long seg[maxn], cnt[maxn];
int n, data[maxn];
void add(int pos, long long tag, long long* seg) {
  for (int t = pos; t <= n; t += t & -t) seg[t] += tag;
}
long long que(int pos, long long* seg) {
  long long ret = 0;
  for (int t = pos; t > 0; t -= t & -t) ret += seg[t];
  return ret;
}
int main() {
  n = qr();
  for (int t = 1; t <= n; ++t) data[t] = n - qr() + 1;
  long double ans = 0, sum = 0;
  for (int t = 1; t <= n; ++t) {
    sum += que(data[t], cnt);
    ans -= que(data[t], seg) * (n - t + 1);
    ans += (long double)(n - t + 1) * t * (t - 1) / (long double)4.0;
    add(data[t], 1, cnt);
    add(data[t], t, seg);
  }
  cout.precision(20);
  cout << ans / (1ll * n * (n + 1) / 2) + sum << endl;
  return 0;
}