#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100005];
int p[100005];
long long size[100005];
struct edge {
  int u, v, w;
  edge(int u = 0, int v = 0, int w = 0) : u(u), v(v), w(w) {}
  bool operator<(const edge &e1) const { return w > e1.w; }
} eList[100005];
int findR(int x) {
  if (p[x] == x) return x;
  return p[x] = findR(p[x]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    eList[i] = edge(u, v, min(a[u], a[v]));
  }
  for (int i = 1; i <= n; i++) {
    p[i] = i;
    size[i] = 1;
  }
  sort(eList + 1, eList + m + 1);
  long long ans = 0;
  int x, y;
  for (int i = 1; i <= m; i++) {
    u = eList[i].u;
    v = eList[i].v;
    x = findR(u);
    y = findR(v);
    if (x != y) {
      ans += eList[i].w * (size[x] * size[y]);
      p[x] = y;
      size[y] += size[x];
    }
  }
  printf("%.6lf", ans * 2.0 / n / (n - 1));
  return 0;
}
