#include <bits/stdc++.h>
using namespace std;
long long a[1000006] = {0};
long long ans[1000006] = {0};
long long last_occ[1000006] = {0};
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(last_occ, 0, sizeof(last_occ));
  memset(ans, 0, sizeof(ans));
  ans[0] = 0;
  double sum = 0.0;
  for (long long i = 1; i <= n; i++) {
    ans[i] = ans[i - 1] + (i - last_occ[a[i]]);
    last_occ[a[i]] = i;
    sum = sum + ans[i];
  }
  double finalAns = 0.0;
  finalAns = (2 * (sum - n) + n) / (n * n * 1.0);
  cout << fixed << setprecision(6) << finalAns << "\n";
}
