#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 100;
long long N, M, dad[MAXN], sz[MAXN];
double ans;
vector<long long> way[MAXN];
pair<long long, long long> ar[MAXN];
bool take[MAXN];
long long findset(long long x) {
  if (x == dad[x]) return x;
  return dad[x] = findset(dad[x]);
}
void unite(long long a, long long b) {
  sz[dad[a]] += sz[dad[b]];
  sz[dad[b]] = 0;
  dad[dad[b]] = dad[a];
}
int main() {
  scanf("%lld%lld", &N, &M);
  for (long long i = 1; i <= N; i++) {
    scanf("%lld", &ar[i].first);
    ar[i].second = i;
    dad[i] = i;
    sz[i] = 1;
  }
  for (long long i = 1, a, b; i <= M; i++) {
    scanf("%lld%lld", &a, &b);
    way[a].push_back(b);
    way[b].push_back(a);
  }
  sort(ar + 1, ar + N + 1);
  reverse(ar + 1, ar + N + 1);
  for (long long i = 1; i <= N; i++) {
    for (long long j = 0; j < (long long)way[ar[i].second].size(); j++)
      if (take[way[ar[i].second][j]] and
          findset(ar[i].second) != findset(way[ar[i].second][j])) {
        ans +=
            sz[dad[ar[i].second]] * sz[dad[way[ar[i].second][j]]] * ar[i].first;
        unite(ar[i].second, way[ar[i].second][j]);
      }
    take[ar[i].second] = 1;
  }
  printf("%lf\n", 2 * ans / (N * (N - 1)));
  return 0;
}
