#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int t;
  t = 1;
  while (t--) {
    long long int n;
    scanf("%lld", &n);
    long long int a[n];
    for (long long int i = 0; i < n; i++) scanf("%lld", &a[i]);
    unordered_map<long long int, long long int> mp;
    for (long long int i = 0; i < n; i++) mp[a[i]] = -1;
    long long int dp[n];
    dp[0] = 1;
    mp[a[0]] = 0;
    for (long long int i = 1; i < n; i++) {
      if (mp[a[i]] != -1)
        dp[i] = dp[i - 1] + (i + 1 - mp[a[i]] - 1);
      else
        dp[i] = dp[i - 1] + (i + 1);
      mp[a[i]] = i;
    }
    float ans = 0.0;
    for (long long int i = 0; i < n; i++) ans += dp[i];
    ans *= 2;
    float fi = (ans - n) / (n * n);
    printf("%.4f\n", fi);
  }
}
