#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u, v, w;
  Edge() {}
  Edge(int tu, int tv, int tw) : u(tu), v(tv), w(tw) {}
  int operator<(const Edge e1) const { return w > e1.w; }
} p[100007];
int n, m;
struct uset {
  int p[100007], sz[100007];
  uset() {}
  uset(int n) {
    for (int i = 1; i <= n; i++) p[i] = i, sz[i] = 1;
  }
  int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }
} us;
double kruskal() {
  us = uset(n);
  sort(p, p + m);
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    int u = p[i].u, v = p[i].v;
    int fx = us.find(u), fy = us.find(v);
    long long s1 = us.sz[fx], s2 = us.sz[fy];
    if (fx != fy) {
      long long cur = (s1 + s2) * (s1 + s2 - 1) - s1 * (s1 - 1) - s2 * (s2 - 1);
      ans += cur * (long long)p[i].w;
      us.p[fx] = fy;
      us.sz[fy] += us.sz[fx];
    }
  }
  return double(ans) / n / (n - 1);
}
int main() {
  int c[100007], u, v;
  for (; cin >> n >> m;) {
    for (int i = 1; i <= n; i++) scanf("%d", c + i);
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &u, &v);
      p[i] = Edge(u, v, min(c[u], c[v]));
    }
    printf("%.9lf\n", kruskal());
  }
  return 0;
}
