#include <bits/stdc++.h>
using namespace std;
const int maxn = 100007;
long long n, m, res, ar[maxn], ata[maxn], size[maxn];
pair<long long, pair<long long, long long> > w[maxn];
int atabul(int nod) {
  return nod == ata[nod] ? nod : ata[nod] = atabul(ata[nod]);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> ar[i], ata[i] = i, size[i] = 1;
  for (int i = 1; i <= m; i++) {
    cin >> w[i].second.first >> w[i].second.second;
    w[i].first = min(ar[w[i].second.first], ar[w[i].second.second]);
  }
  sort(w + 1, w + m + 1);
  for (int i = m; i >= 1; i--) {
    long long atax, atay, c;
    atax = (atabul(w[i].second.first));
    atay = (atabul(w[i].second.second));
    c = w[i].first;
    if (atax != atay) {
      res += size[atax] * size[atay] * c;
      size[atax] += size[atay];
      ata[atay] = ata[atax];
    }
  }
  cout << (2.0 * res) / (n * (n - 1)) << endl;
  return 0;
}
