#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int st, ed;
  long long v;
} edge[200005];
int fa[200005], cnt[200005];
long long ans, V[200005];
bool cmp(Edge x, Edge y) { return x.v > y.v; }
int getfa(int x) {
  if (fa[x] != x) fa[x] = getfa(fa[x]);
  return fa[x];
}
void Union(int x, int y, long long t) {
  x = getfa(x);
  y = getfa(y);
  if (x != y) {
    fa[x] = y;
    ans += (long long)cnt[x] * (long long)cnt[y] * t;
    cnt[y] += cnt[x];
  }
}
int main() {
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%lld", &V[i]);
    fa[i] = i;
    cnt[i] = 1;
  }
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &edge[i].st, &edge[i].ed);
    edge[i].v = min(V[edge[i].st], V[edge[i].ed]);
  }
  sort(edge + 1, edge + m + 1, cmp);
  for (i = 1; i <= m; ++i) Union(edge[i].st, edge[i].ed, edge[i].v);
  printf("%lf\n", ans * 2.0 / (1ll * n * (n - 1)));
}
