#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ll n,x;
cin>>n;
double sum=0;
//unique contains the all subarray ending at that position and the count of unique elemnts of all subarrays
vector unique(n+1),last_occurance(1000006);
for(ll i=1;i<=n;i++){
cin>>x;
unique[i]=unique[i-1]+i-last_occurance[x];
last_occurance[x]=i;
sum+=(unique[i]);
}
cout<<fixed<<setprecision(6)<<(2*(sum-n)+n)/(n*n);
return 0;
}