#include <bits/stdc++.h>
using namespace std;
int n, m, cost[100003], parents[100003], ranks[100003];
pair<int, pair<int, int> > edges[100003];
long long ans;
bool comparator(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.first > b.first;
}
int findParent(int a) {
  if (a == parents[a]) return a;
  return parents[a] = findParent(parents[a]);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> cost[i];
    parents[i] = i;
    ranks[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edges[i].second.first >> edges[i].second.second;
    edges[i].first =
        min(cost[edges[i].second.first], cost[edges[i].second.second]);
  }
  sort(edges + 1, edges + m + 1, comparator);
  for (int i = 1; i <= m; i++) {
    int pa = findParent(edges[i].second.first);
    int push_back = findParent(edges[i].second.second);
    if (pa != push_back) {
      ans += 1ll * edges[i].first * ranks[pa] * ranks[push_back];
      parents[pa] = push_back;
      ranks[push_back] += ranks[pa];
    }
  }
  printf("%.6lf", ans * 2.0 / n / (n - 1));
}
