#include <bits/stdc++.h>
using namespace std;
int las[1001000];
int n;
long long tot, now;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    if (las[x]) now -= las[x];
    tot += now + i - 1;
    now += i;
    las[x] = i;
  }
  tot <<= 1;
  tot += n;
  double ans = tot * 1.0 / (1LL * n * n);
  printf("%.10lf\n", ans);
  return 0;
}
