#include <bits/stdc++.h>
using namespace std;
const int size = 1e6 + 7;
const int mod = 1e9 + 7;
vector<int> v[size];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int n, i, j, x;
  long long ans = 0;
  cin >> n;
  for (i = 1; i < size; i++) v[i].push_back(0);
  for (i = 1; i <= n; i++) {
    cin >> x;
    v[x].push_back(i);
  }
  for (i = 1; i < size; i++) {
    if (v[i].size() > 1) {
      for (j = 1; j < v[i].size(); j++) {
        ans += 2 * (v[i][j] - v[i][j - 1]) * 1ll * (n - v[i][j] + 1) - 1;
      }
    }
  }
  cout << setprecision(6) << fixed;
  cout << (1.0 * ans) / (n * 1ll * n);
  return 0;
}
