#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T, class X>
inline bool getbit(T a, X i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class X>
inline T setbit(T a, X i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class X>
inline T resetbit(T a, X i) {
  T t = 1;
  return (a & (~(t << i)));
}
long long n, arr[1000009];
vector<long long> vec[1000009];
int main() {
  scanf("%lld", &n);
  for (int i = (1); i <= (1000000); i++) vec[i].push_back(0);
  for (int i = (1); i <= (n); i++) {
    scanf("%lld", &arr[i]);
    vec[arr[i]].push_back(i);
  }
  long long cnt = 0, temp;
  for (int i = (1); i <= (1000000); i++) {
    temp = 0;
    vec[i].push_back(n + 1);
    for (int j = (0); j <= (vec[i].size() - 2); j++)
      temp += (vec[i][j + 1] - vec[i][j] - 1) * (vec[i][j + 1] - vec[i][j] - 1);
    cnt += n * n - temp;
  }
  double ans = cnt, vaag = n * n;
  ans /= vaag;
  printf("%.7f\n", ans);
  return 0;
}
