#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
struct PP {
  int value, x, y;
};
int n, m, a[100100], sl[100100], f[100100];
long long res;
PP p[100100];
bool cmp(PP x, PP y) { return x.value > y.value; }
int Get(int i) {
  if (f[i] == i) return i;
  f[i] = Get(f[i]);
  return f[i];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
    p[i].value = min(a[p[i].x], a[p[i].y]);
  }
  sort(p + 1, p + m + 1, cmp);
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    sl[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int x = Get(p[i].x), y = Get(p[i].y);
    if (x != y) {
      res += (long long)sl[x] * sl[y] * p[i].value;
      sl[y] += sl[x];
      f[x] = y;
    }
  }
  cout << (double)res * 2 / ((long long)n * (n - 1));
  return 0;
}
