#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powm(long long base, long long exp, long long mod = 998244353) {
  base %= mod;
  long long ans = 1;
  while (exp) {
    if (exp & 1LL) ans = (ans * base) % mod;
    exp >>= 1LL, base = (base * base) % mod;
  }
  return ans;
}
long long a[100005];
vector<pair<long long, pair<long long, long long> > > e;
long long dsu[100005];
long long sz[100005];
long long root(int x) {
  while (dsu[x] != x) {
    x = dsu[dsu[x]];
  }
  return x;
}
void wu(int x, int y) {
  int rx = root(x);
  int ry = root(y);
  if (rx == ry) return;
  if (sz[rx] < sz[ry]) {
    dsu[rx] = ry;
    sz[ry] += sz[rx];
  } else {
    dsu[ry] = rx;
    sz[rx] += sz[ry];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    e.push_back({min(a[x], a[y]), {x, y}});
  }
  sort(e.begin(), e.end(),
       greater<pair<long long, pair<long long, long long> > >());
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    dsu[i] = i;
    sz[i] = 1;
  }
  for (auto it : e) {
    long long x = it.second.first;
    long long y = it.second.second;
    long long w = it.first;
    if (root(x) == root(y)) continue;
    ans += 2 * w * sz[root(x)] * sz[root(y)];
    wu(x, y);
  }
  cout << std::fixed << std::setprecision(10)
       << (long double)ans / (n * (n - 1)) << '\n';
}
