#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
int a[maxn];
int p[maxn];
int s[maxn];
vector<pair<int, int> > e[maxn];
int root(int x) { return x == p[x] ? x : p[x] = root(p[x]); }
long long ans;
void joint(int x, int y, int cur) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  ans += 1ll * s[x] * s[y] * cur;
  if (s[y] <= s[x]) {
    p[x] = y;
    s[y] += s[x];
  } else {
    p[y] = x;
    s[x] += s[y];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int _n(n), i(0); i < _n; i++) cin >> a[i];
  for (int _n(n), i(0); i < _n; i++) p[i] = i, s[i] = 1;
  for (int _n(m), i(0); i < _n; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    int w = min(a[u], a[v]);
    e[w].push_back(make_pair(u, v));
  }
  ans = 0;
  for (int i = maxn - 1; i >= 0; --i) {
    for (int _n((int)e[i].size()), j(0); j < _n; j++) {
      int u = e[i][j].first;
      int v = e[i][j].second;
      joint(u, v, i);
    }
  }
  cout << fixed << setprecision(9) << 2.0 * ans / n / (n - 1) << endl;
  return 0;
}
