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;
int A[100005];
pair<long long, long long> tree[500005];
long long treeR[500005];
long long cum[100005];
long long cumR[100005];
double dp[100005];
void update(int a, int l, int r, int node, int i) {
  if (l > a || r < a) return;
  if (l == a && l == r) {
    tree[node].first = i;
    tree[node].second = 1;
    return;
  }
  update(a, l, (l + r) / 2, 2 * node, i);
  update(a, (l + r) / 2 + 1, r, 2 * node + 1, i);
  tree[node] = make_pair(tree[2 * node].first + tree[2 * node + 1].first,
                         tree[2 * node].second + tree[2 * node + 1].second);
}
pair<long long, long long> query(int a, int b, int l, int r, int node) {
  if (l > b || r < a) return make_pair(0, 0);
  if (l >= a && r <= b) return tree[node];
  pair<long long, long long> lef = query(a, b, l, (l + r) / 2, 2 * node);
  pair<long long, long long> righ =
      query(a, b, (l + r) / 2 + 1, r, 2 * node + 1);
  return make_pair(lef.first + righ.first, lef.second + righ.second);
}
void updateR(int a, int l, int r, int node) {
  if (l > a || r < a) return;
  if (l == a && l == r) {
    treeR[node] = a;
    return;
  }
  updateR(a, l, (l + r) / 2, 2 * node);
  updateR(a, (l + r) / 2 + 1, r, 2 * node + 1);
  treeR[node] = treeR[2 * node] + treeR[2 * node + 1];
}
long long queryR(int a, int b, int l, int r, int node) {
  if (l > b || r < a) return 0;
  if (l >= a && r <= b) return treeR[node];
  long long lef = queryR(a, b, l, (l + r) / 2, 2 * node);
  long long righ = queryR(a, b, (l + r) / 2 + 1, r, 2 * node + 1);
  return lef + righ;
}
int main() {
  long long int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &A[i]);
  }
  double ans = 0;
  for (long long int i = 1; i <= n; ++i) {
    update(A[i], 1, 100001, 1, i);
    pair<long long, long long> need = query(A[i] + 1, 100001, 1, 100001, 1);
    ans += (((n * (n + 1)) / 2.0) * need.second - (need.first) * (n - i + 1.0));
  }
  dp[1] = 0;
  for (int i = 2; i <= 100000; ++i) {
    dp[i] = (1.0 * i - 1.0) / 2.0 + dp[i - 1];
  }
  for (int i = 1; i <= n; ++i) ans += 1.0 * (n - i + 1) * dp[i];
  ans = ans / (1.0 * n);
  ans = ans / (1.0 * (n + 1.0));
  ans = ans * 2.0;
  printf("%.10f\n", ans);
  return 0;
}