#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100 * 1000 + 100;
long long a[maxn], par[maxn], t[maxn];
long double ans;
vector<pair<long long, pair<long long, long long> > > vec;
long long get_par(long long v) {
  return par[v] = (par[v] == v ? v : get_par(par[v]));
}
int32_t main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    vec.push_back(make_pair(min(a[x], a[y]), make_pair(x, y)));
  }
  sort(vec.begin(), vec.end(),
       greater<pair<long long, pair<long long, long long> > >());
  for (long long i = 0; i < n; i++) {
    par[i] = i;
    t[i] = 1;
  }
  for (long long i = 0; i < (long long)vec.size(); i++) {
    long long x = get_par(vec[i].second.first);
    long long y = get_par(vec[i].second.second);
    if (x != y) {
      ans += t[x] * t[y] * vec[i].first;
      t[y] += t[x];
      par[x] = y;
    }
  }
  ans *= 2;
  ans /= (long double)(n) * (n - 1);
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}
