#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
double f[N];
int n, m, k;
int pre[N], a[N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  double ans = 0.0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    f[i] = f[i - 1] + i - pre[a[i]];
    ans += 2.0 * f[i] - 1;
    pre[a[i]] = i;
  }
  printf("%.6f\n", ans / (1.0 * n * n));
  return 0;
}
