#include <bits/stdc++.h>
using namespace std;
int node_val[100005];
struct Edge {
  int u, v, val;
  bool operator<(const Edge& ref) const { return val > ref.val; }
} edge[100005 * 2];
int fa[100005], cnt[100005];
void init(int n) {
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    cnt[i] = 1;
  }
}
int findx(int x) {
  if (fa[x] == x) return x;
  return fa[x] = findx(fa[x]);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &node_val[i]);
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    edge[i].u = x, edge[i].v = y, edge[i].val = min(node_val[x], node_val[y]);
  }
  sort(edge, edge + m);
  double exp = 0;
  init(n);
  for (int i = 0; i < m; i++) {
    int u = edge[i].u, v = edge[i].v;
    int fu = findx(u), fv = findx(v);
    if (fu != fv) {
      fa[fu] = fv;
      exp += (double)cnt[fv] * cnt[fu] * edge[i].val;
      cnt[fv] += cnt[fu];
    }
  }
  double all = (double)n * (n - 1) / 2;
  printf("%.6f\n", exp / all);
  return 0;
}
