#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
struct el {
  int x, y, t;
};
int n, m, a[MAXN];
el edges[MAXN];
vector<int> groups[MAXN];
int groupIndex[MAXN];
long long ans;
void read() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &edges[i].x, &edges[i].y);
    edges[i].t = min(a[edges[i].x], a[edges[i].y]);
  }
}
bool cmp(el p, el q) { return p.t > q.t; }
void mergeGroups(int i, int j) {
  int sz1 = (int)groups[i].size();
  int sz2 = (int)groups[j].size();
  if (sz2 > sz1) i ^= j ^= i ^= j;
  while (!groups[j].empty()) {
    int l = groups[j].back();
    groups[j].pop_back();
    groupIndex[l] = i;
    groups[i].push_back(l);
  }
}
void solve() {
  sort(edges, edges + m, cmp);
  for (int i = 1; i <= n; i++) {
    groups[i].push_back(i);
    groupIndex[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int x = edges[i].x;
    int y = edges[i].y;
    int idx1 = groupIndex[x];
    int idx2 = groupIndex[y];
    if (idx1 == idx2) continue;
    ans += 2LL * (long long)edges[i].t * (long long)groups[idx1].size() *
           (long long)groups[idx2].size();
    mergeGroups(idx1, idx2);
  }
  cout.precision(6);
  cout << fixed << ((long double)ans / (long double)n) / (long double)(n - 1)
       << endl;
}
int main() {
  read();
  solve();
  return 0;
}
