#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 10;
long long a[maxn];
struct edge {
  long long u, v, c;
  edge(long long uu, long long vv, long long cc) : u(uu), v(vv), c(cc) {}
};
vector<edge> g, adj;
long long p[maxn], sz[maxn];
long long find(long long x) { return p[x] = (p[x] == x) ? x : find(p[x]); }
void join(long long a, long long b) {
  sz[find(a)] += sz[find(b)];
  p[find(b)] = find(a);
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i], p[i] = i;
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    g.push_back({x, y, min(a[x], a[y])});
  }
  sort(g.begin(), g.end(), [](edge a, edge b) { return a.c > b.c; });
  for (long long i = 0; i < m; i++) {
    edge e = g[i];
    if (find(e.u) == find(e.v)) continue;
    join(e.v, e.u);
    adj.push_back(e);
  }
  for (long long i = 1; i <= n; i++) p[i] = i, sz[i] = 1;
  double ans = 0;
  for (long long i = 0; i < adj.size(); i++) {
    edge e = adj[i];
    long long x = sz[find(e.u)], y = sz[find(e.v)];
    ans += e.c * x * y;
    join(e.u, e.v);
  }
  double denom = n * (n - 1) * 0.5;
  printf("%0.12lf\n", ans / denom);
  return 0;
}
