#include <bits/stdc++.h>
using namespace std;
long long n, v[123456], sz[123456];
int m, a, b, ord[123456], rep[123456];
char s[123456];
long double ans;
bool cmp(int a, int b) { return v[a] > v[b]; }
vector<int> al[123456], us;
int findr(int at) {
  if (at == rep[at]) return at;
  return rep[at] = findr(rep[at]);
}
int main() {
  scanf("%lld %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld", v + i);
    ord[i] = rep[i] = i;
    sz[i] = 1;
  }
  sort(ord, ord + n, cmp);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    al[a].push_back(b);
    al[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    int at = ord[i], ra = findr(at);
    long long tcon = 1;
    s[at] = 1;
    us.clear();
    for (int j = 0; j < al[at].size(); j++) {
      int to = al[at][j];
      if (s[to]) us.push_back(findr(to));
    }
    sort(us.begin(), us.end());
    for (int j = 0; j < us.size(); j++)
      if (!j || us[j] != us[j - 1]) tcon += sz[us[j]];
    for (int j = 0; j < us.size(); j++)
      if (!j || us[j] != us[j - 1]) {
        ans += v[at] * (tcon - sz[us[j]]) * sz[us[j]];
        rep[us[j]] = at;
        sz[ra] += sz[us[j]];
      }
    ans += v[at] * (tcon - 1);
  }
  printf("%lf\n", (double)(ans / (n * n - n)));
  return 0;
}
