#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int l[1000006];
int p[1000006];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = (1); i < ((n) + 1); i++) {
    int v;
    cin >> v;
    l[i] = p[v];
    p[v] = i;
  }
  long long ans = 0;
  for (int i = (1); i < ((n) + 1); i++) ans += 1ll * (i - l[i]) * (n - i + 1);
  ans = 2 * ans - n;
  long double k = ans;
  k /= (1.L * n) * n;
  cout << fixed << setprecision(18) << k << endl;
}
