#include <bits/stdc++.h>
using namespace std;
const int MAX = 110000;
int n, m, v[MAX], p[MAX], s[MAX];
pair<int, int> t[MAX];
bool cmp(pair<int, int> x, pair<int, int> y) {
  return min(v[x.first], v[x.second]) > min(v[y.first], v[y.second]);
}
int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }
void join(int x, int y) {
  s[x] += s[y];
  p[y] = x;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]), p[i] = i, s[i] = 1;
  for (int i = 0; i < (int)(m); i++) scanf("%d %d", &t[i].first, &t[i].second);
  sort(t, t + m, cmp);
  long double ans = 0.0;
  for (int i = 0; i < (int)(m); i++) {
    int x = t[i].first, y = t[i].second, cost = min(v[x], v[y]);
    x = find(x);
    y = find(y);
    if (x == y) continue;
    ans += (long double)cost * s[x] * s[y];
    join(x, y);
  }
  printf("%.6lf\n", (double)(ans * 2 / n / (n - 1)));
  return 0;
}
