#include <bits/stdc++.h>
using namespace std;
int const max_n = 1e5 + 1;
int a[max_n], par[max_n], sz[max_n];
double sum;
vector<pair<int, pair<int, int> > > adj;
int get_par(int v) { return par[v] < 0 ? v : get_par(par[v]); }
void merge(int v, int u, int w) {
  v = get_par(v);
  u = get_par(u);
  if (u != v) {
    if (sz[v] > sz[u]) swap(v, u);
    sum += (double)w * sz[v] * sz[u];
    sz[u] += sz[v];
    par[v] = u;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  fill(par, par + n, -1);
  fill(sz, sz + n, 1);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) {
    int v, u;
    cin >> v >> u;
    --v;
    --u;
    adj.push_back(
        pair<int, pair<int, int> >{min(a[u], a[v]), pair<int, int>{v, u}});
  }
  sort(adj.begin(), adj.begin() + m);
  reverse(adj.begin(), adj.begin() + m);
  for (int i = 0; i < m; ++i)
    merge(adj[i].second.first, adj[i].second.second, adj[i].first);
  sum /= ((double)n * (n - 1)) / 2;
  cout << fixed << setprecision(4) << sum << '\n';
  return 0;
}
