#include <bits/stdc++.h>
using namespace std;
long long animals[100009];
int father[100009];
long long weight[100009];
int find(int u) {
  if (father[u] == u) return u;
  int next = father[u];
  father[u] = father[next];
  return find(next);
}
void setUnion(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return;
  if (weight[u] > weight[v]) swap(u, v);
  weight[v] += weight[u];
  father[u] = v;
}
bool compare(int u, int v) { return animals[u] > animals[v]; }
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 1; i <= N; i++) {
    cin >> animals[i];
    father[i] = i;
    weight[i] = 1;
    vec[i - 1] = i;
  }
  vector<vector<int> > G(N + 1);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  sort(vec.begin(), vec.end(), compare);
  long long res = 0;
  for (int i = 0; i < vec.size(); i++) {
    int curr = vec[i];
    for (int j = 0; j < G[curr].size(); j++) {
      int neigh = G[curr][j];
      if (animals[neigh] < animals[curr] || find(curr) == find(neigh)) continue;
      res += animals[curr] * (weight[find(curr)] * weight[find(neigh)]);
      setUnion(curr, neigh);
    }
  }
  long long NMAX = (long long)N * (long long)(N - 1);
  cout.precision(15);
  cout << (double)(res * 2) / (double)NMAX;
  return 0;
}
