#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
const int M = 111111;
int val[N];
pair<int, pair<int, int> > edge[M];
int n, m;
int fa[N], cnt[N];
void init() {
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    cnt[i] = 1;
  }
}
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
bool Union(int a, int b) {
  a = find(a), b = find(b);
  if (a == b) return false;
  cnt[a] += cnt[b];
  fa[b] = a;
  return true;
}
void solve() {
  sort(edge, edge + m);
  reverse(edge, edge + m);
  init();
  double ans = 0;
  for (int i = 0; i < m; i++) {
    int a = edge[i].second.first, b = edge[i].second.second;
    int ra = find(a), rb = find(b);
    if (ra == rb) continue;
    ans += edge[i].first * (1.0 * cnt[ra] * cnt[rb]);
    cnt[ra] += cnt[rb];
    fa[rb] = fa[ra];
  }
  ans *= 2;
  ans /= n;
  ans /= (n - 1);
  printf("%.20f\n", ans);
}
int main() {
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++) cin >> val[i];
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      int c = min(val[a], val[b]);
      edge[i] = make_pair(c, make_pair(a, b));
    }
    solve();
  }
  return 0;
}
