#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, a[maxn], fa[maxn], sz[maxn];
long long ans;
struct edge {
  int u, v, w;
  bool operator<(const edge &other) const { return w > other.w; }
} e[maxn * 10];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]), fa[i] = i, sz[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &e[i].u, &e[i].v), e[i].w = min(a[e[i].u], a[e[i].v]);
  }
  sort(e + 1, e + m + 1);
  for (int i = 1; i <= m; i++) {
    int u = find(e[i].u), v = find(e[i].v);
    if (u == v) continue;
    ans += 2LL * e[i].w * sz[u] * sz[v], fa[u] = v, sz[v] += sz[u];
  }
  printf("%.4f\n", 1.0 * ans / n / (n - 1));
  return 0;
}
