#include <bits/stdc++.h>
const int maxn = 1e6;
using namespace std;
long long n;
int a[maxn + 5];
int l[maxn + 5];
void solve() {
  long long cnt;
  double tot = 0;
  memset(l, 0, sizeof(l));
  for (int i = 1; i <= n; i++) {
    cnt = (i - l[a[i]]) * (n - i + 1) * 2 - 1;
    tot += cnt * 1.0;
    l[a[i]] = i;
  }
  double ans = tot * 1.0 / n / n;
  printf("%.6lf\n", ans);
}
int main() {
  while (~scanf("%I64d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    solve();
  }
  return 0;
}
