#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz";
const long long mod = 1e9 + 7;
const long long inf = 2e18 + 5;
const long long nax = 101010;
long long a[nax];
long long parent[nax];
long long sz[nax];
long long root(long long x) {
  while (parent[x] != x) {
    parent[x] = parent[parent[x]];
    x = parent[x];
  }
  return x;
}
void join(long long u, long long v) {
  long long r1 = root(u);
  long long r2 = root(v);
  if (r1 == r2) return;
  parent[r1] = r2;
  sz[r2] += sz[r1];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = (1); i < (n + 1); i++) cin >> a[i];
  vector<pair<long long, pair<long long, long long>>> E;
  for (long long i = (0); i < (m); i++) {
    long long u, v;
    cin >> u >> v;
    long long w = min(a[u], a[v]);
    E.push_back({w, {u, v}});
  }
  sort(E.begin(), E.end());
  reverse(E.begin(), E.end());
  double res = 0;
  double total = (n * (n - 1)) / 2;
  for (long long i = (0); i < (nax); i++) {
    sz[i] = 1;
    parent[i] = i;
  }
  for (auto e : E) {
    long long w = e.first;
    long long u = e.second.first;
    long long v = e.second.second;
    if (root(u) == root(v)) continue;
    res += w * sz[root(u)] * sz[root(v)];
    join(u, v);
  }
  res = res / total;
  cout << setprecision(10);
  cout << res;
  return 0;
}
