#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct DSU {
    vector<int> p;
    vector<ll> s;
    DSU(int n) : p(n), s(n, 1) {
        iota(p.begin(), p.end(), 0);
    }
    int find(int x) {
        while (p[x] != x)
            x = p[x] = p[p[x]];
        return x;
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int &x : a)
        cin >> x;
    vector<tuple<int, int, int>> edges;
    while (m--) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        edges.push_back({min(a[u], a[v]), u, v});
    }
    sort(edges.rbegin(), edges.rend());
    DSU d(n);
    ll total = 0;
    for (auto [w, u, v] : edges) {
        u = d.find(u);
        v = d.find(v);
        if (u == v)
            continue;
        total += 1LL * w * d.s[u] * d.s[v];
        if (d.s[u] < d.s[v])
            swap(u, v);
        d.p[v] = u;
        d.s[u] += d.s[v];
    }
    cout << fixed << setprecision(12) << (long double)total / (1LL * n * (n - 1) / 2)
         << '\n';
}
