#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000111;
int fu[MAXN];
void ustaw(int n) {
  for (int i = 1; i <= n; i++) fu[i] = -1;
}
int find(int v) {
  if (fu[v] < 0) return v;
  fu[v] = find(fu[v]);
  return fu[v];
}
double wyn = 0;
int unia(int a, int b, double val) {
  int aa = find(a), bb = find(b);
  if (aa == bb) return 0;
  double fa = -fu[aa], fb = -fu[bb];
  wyn += fa * fb * val;
  if (fu[aa] > fu[bb]) swap(aa, bb);
  fu[aa] += fu[bb];
  fu[bb] = aa;
  return 1;
}
int t[MAXN];
pair<int, pair<int, int> > kraw[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  ustaw(n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    kraw[i] = {min(t[a], t[b]), {a, b}};
  }
  sort(kraw + 1, kraw + m + 1);
  for (int i = m; i > 0; i--) {
    int a, b;
    tie(a, b) = kraw[i].second;
    int val = kraw[i].first;
    unia(a, b, val);
  }
  wyn *= 2;
  double wynik = wyn;
  long long nn = n;
  wynik /= (nn * (nn - 1));
  printf("%.9lf\n", wynik);
}
