#include <bits/stdc++.h>
using namespace std;
const int maxn = 100101;
int n, m, w[maxn], fa[maxn], size[maxn];
struct edge {
  int l, r, v;
  bool operator<(const edge &a) const { return v > a.v; }
} e[maxn];
int get(int x) {
  if (fa[x] == x) return x;
  return fa[x] = get(fa[x]);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  for (int i = 1; i <= m; ++i) {
    int l, r;
    scanf("%d%d", &e[i].l, &e[i].r);
    e[i].v = min(w[e[i].l], w[e[i].r]);
  }
  for (int i = 1; i <= n; ++i) fa[i] = i, size[i] = 1;
  sort(e + 1, e + m + 1);
  double ans = 0;
  for (int i = 1; i <= m; ++i) {
    if (get(e[i].l) == get(e[i].r)) continue;
    ans += (double)size[get(e[i].l)] * size[get(e[i].r)] * e[i].v;
    size[get(e[i].r)] += size[get(e[i].l)];
    fa[get(e[i].l)] = get(e[i].r);
  }
  ans *= 2;
  ans /= (double)n * (n - 1);
  printf("%.6f\n", ans);
  return 0;
}
