#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const int maxn = 1e6 + 5;
int n, m;
int a[maxn];
vector<int> g[maxn];
vector<pair<int, pair<int, int>>> edges;
int par[maxn], siz[maxn];
int f(int x) { return par[x] == x ? x : par[x] = f(par[x]); }
void join(int x, int y) {
  x = f(x);
  y = f(y);
  if (x == y) return;
  if (siz[x] < siz[y]) swap(x, y);
  siz[x] += siz[y];
  par[y] = x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    par[i] = i;
    siz[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    edges.push_back({min(a[u], a[v]), {u, v}});
  }
  auto cmp = [](pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2) {
    return p1.first > p2.first;
  };
  long double num = 0;
  long double den = 0;
  sort(edges.begin(), edges.end(), cmp);
  for (auto p : edges) {
    int wei = p.first;
    int u = f(p.second.first);
    int v = f(p.second.second);
    if (u == v) continue;
    long double paths = 1LL * siz[u] * siz[v];
    den += paths;
    num += 1.0 * wei * paths;
    join(u, v);
  }
  long double ans = num / den;
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}
