#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long par[100005], siz[100005], a[100005];
struct edge {
  long long a, b, w;
} edges[100005];
bool operator<(edge a, edge b) { return a.w < b.w; }
long long findr(long long x) {
  if (par[x] == x) return x;
  return par[x] = findr(par[x]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    siz[i] = 1;
    par[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    edges[i].a = x;
    edges[i].b = y;
    edges[i].w = min(a[x], a[y]);
  }
  sort(edges + 1, edges + m + 1);
  long long ans = 0;
  for (int i = m; i > 0; i--) {
    long long u = findr(edges[i].a);
    long long v = findr(edges[i].b);
    if (u == v) continue;
    ans += siz[u] * siz[v] * edges[i].w;
    par[v] = u;
    siz[u] += siz[v];
  }
  cout << fixed << setprecision(8) << (double)ans * 2 / (n * (n - 1)) << endl;
  return 0;
}
