#include <bits/stdc++.h>
using namespace std;
int gcd(int u, int v) { return (v != 0) ? gcd(v, u % v) : u; }
struct disjoint_sets {
  int parent[100000 + 10];
  int ccOfParent[100000 + 10];
  int cc;
  disjoint_sets(int V) {
    cc = V;
    for (int i = 1; i <= V; i++) parent[i] = i, ccOfParent[i] = 1;
  }
  int getParent(int a) {
    if (parent[a] == a) return a;
    return parent[a] = getParent(parent[a]);
  }
  void link(int a, int b) {
    ccOfParent[getParent(b)] += ccOfParent[getParent(a)];
    ccOfParent[getParent(a)] = ccOfParent[getParent(b)];
    parent[getParent(a)] = getParent(b);
  }
  bool unionSets(int a, int b) {
    int p1 = getParent(a);
    int p2 = getParent(b);
    if (p1 == p2) return 0;
    link(a, b);
    cc--;
    return 1;
  }
};
vector<int> adj[100000 + 10];
int V, E;
vector<pair<int, int> > vec;
bool vis[100000 + 10] = {0};
double solve() {
  disjoint_sets s(V);
  long long total = 0;
  for (int i = 0; i < V; i++) {
    int a = vec[i].second;
    long long cost = vec[i].first;
    for (int j = 0; j < adj[a].size(); j++) {
      int b = adj[a][j];
      if (!vis[b]) continue;
      int cc1 = s.ccOfParent[s.getParent(a)];
      int cc2 = s.ccOfParent[s.getParent(b)];
      if (s.unionSets(a, b)) total += 2 * cost * cc1 * cc2;
    }
    vis[a] = 1;
  }
  return (total / ((double)V * (V - 1)));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> V >> E;
  vec.resize(V);
  for (int i = 1; i <= V; i++) cin >> vec[i - 1].first, vec[i - 1].second = i;
  int a, b;
  for (int j = 0; j < E; j++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  sort(vec.rbegin(), vec.rend());
  double res = solve();
  cout << res << endl;
}
