#include <bits/stdc++.h>
using namespace std;
int siz[100005];
int dsu[100005];
struct edge {
  int a, b;
  double c;
  bool operator<(const edge& t) const { return c > t.c; }
} g[100005];
int find(int a) { return a == dsu[a] ? a : dsu[a] = find(dsu[a]); }
int arr[100005];
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> arr[i], dsu[i] = i, siz[i] = 1;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[i].a = a;
    g[i].b = b;
    g[i].c = min(arr[a], arr[b]);
  }
  sort(g, g + m);
  double ans = 0;
  for (int i = 0; i < m; i++) {
    int a = find(g[i].a);
    int b = find(g[i].b);
    if (a != b) {
      ans += g[i].c * siz[a] * siz[b];
      dsu[b] = a;
      siz[a] += siz[b];
    }
  }
  cout << ans * 2 / n / (n - 1);
}
