#include <bits/stdc++.h>
using namespace std;
struct edge {
  int a, b, c;
} a[100005];
int s[100005], p[100005], d[100005], n, m, i, j;
double ans;
int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }
long long fang(long long a, long long b, long long mo) {
  long long ans = 1;
  for (; b; b >>= 1) b& 1 ? ans = ans * a % mo : 0, a = a * a % mo;
  return ans;
}
template <class T>
void up(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
void down(T& a, T b) {
  if (a > b) a = b;
}
int comp(const void* a, const void* b) { return ((edge*)b)->c - ((edge*)a)->c; }
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &d[i]), p[i] = i, s[i] = 1;
  for (i = 1; i <= m; i++)
    scanf("%d%d", &a[i].a, &a[i].b), a[i].c = min(d[a[i].a], d[a[i].b]);
  qsort(a + 1, m, sizeof(edge), comp);
  for (i = 1, j = n - 1; j; i++)
    if (find(a[i].a) != find(a[i].b))
      ans += (double)s[p[a[i].b]] * s[p[a[i].a]] * a[i].c,
          s[p[a[i].b]] += s[p[a[i].a]], p[p[a[i].a]] = p[a[i].b], j--;
  printf("%.6f", 2 * ans / n / (n - 1));
  return 0;
}
