#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
long long a[maxn];
long long f[maxn];
int main() {
  long long n;
  scanf("%lld", &n);
  memset(f, 0, sizeof(f));
  for (long long i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += (i - f[a[i]]) * (n - i + 1);
    f[a[i]] = i;
  }
  ans = ans * 2 - n;
  printf("%.6f\n", (double)(ans * 1.0) / ((long long)(n * n)));
}
