#include <bits/stdc++.h>
using namespace std;
long long x, mp[1000005], sum, n, i = 1;
int main() {
  for (cin >> n; i <= n && cin >> x; mp[x] = i++)
    sum += (i - mp[x]) * (n + 1 - i) * 2 - 1;
  cout << fixed << setprecision(10) << (long double)sum / n / n;
}
