#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long INF = 1e18 + 7;
const int maxn = 1e6 + 7;
long long n, a[maxn], first[maxn];
double sum;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    sum += (((i - first[a[i]]) * (n - i + 1)) * 2.0 - 1.0) / n / n;
    first[a[i]] = i;
  }
  cout << fixed << setprecision(6) << sum;
  return 0;
}
