#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<int, int> > > E;
int pset[100200];
long long size[100200];
int find(int i) {
  if (pset[i] == i) return i;
  return pset[i] = find(pset[i]);
}
void join(int i, int j) {
  int X = find(i);
  int Y = find(j);
  size[Y] += size[X];
  pset[X] = Y;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long v[100200];
long long ans = 0;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", &v[i]);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    E.push_back(make_pair(min(v[a], v[b]), make_pair(a, b)));
  }
  for (int i = 1; i <= n; i++) pset[i] = i;
  for (int i = 1; i <= n; i++) size[i] = 1;
  double res = n * (n - 1);
  sort(E.begin(), E.end());
  for (int i = E.size() - 1; i >= 0; i--) {
    int u = E[i].second.first;
    int v = E[i].second.second;
    long long c = E[i].first;
    if (find(u) != find(v)) {
      int X = find(u);
      int Y = find(v);
      ans += (size[X] * size[Y] * c);
      join(u, v);
    }
  }
  double re = (double)ans;
  printf("%lf", 2 * re / n / (n - 1));
}
