#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int fa[MAXN];
long long sum[MAXN];
struct Edge2 {
  int u, v, dist;
  bool operator<(const Edge2& t) const { return dist > t.dist; }
} e[MAXN];
int find(int u) { return fa[u] == u ? fa[u] : fa[u] = find(fa[u]); }
int w[MAXN];
int main() {
  for (int i = 0; i < MAXN; i++) fa[i] = i, sum[i] = 1LL;
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &w[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &e[i].u, &e[i].v);
    e[i].dist = min(w[e[i].u], w[e[i].v]);
  }
  sort(e, e + m);
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    int u = find(e[i].u);
    int v = find(e[i].v);
    if (u != v) {
      fa[u] = v;
      ans += e[i].dist * sum[u] * sum[v];
      sum[v] += sum[u];
    }
  }
  printf("%.7f\n", double(ans) * 2 / (n * double(n - 1)));
  return 0;
}
