#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n + 1);
  vector<long long> dp(n + 1);
  vector<int> hash(1000006);
  long long cumsum = 0;
  for (int i = 1; i < n + 1; i++) cin >> v[i];
  for (int i = 1; i < n + 1; i++) {
    dp[i] = dp[i - 1] + i - hash[v[i]];
    cumsum += dp[i];
    hash[v[i]] = i;
  }
  double res = 0.0;
  res = (double)(2 * (cumsum - n) + n) * (1.0) / (1.0 * n) / (1.0 * n);
  cout << fixed << setprecision(6) << res;
}
