#include <bits/stdc++.h>
using namespace std;
int n, m;
int n1, n2;
int v[100010];
int sz[100010];
int pai[100010];
vector<pair<int, pair<int, int> > > edges;
int find(int i) {
  if (i == pai[i]) return i;
  return pai[i] = find(pai[i]);
}
void join(int i, int j) {
  if (sz[i] < sz[j]) swap(sz[i], sz[j]);
  pai[j] = i;
  sz[i] += sz[j];
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
    sz[i] = 1;
    pai[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &n1, &n2);
    int W = min(v[n1], v[n2]);
    edges.push_back({W, {n1, n2}});
  }
  sort(edges.begin(), edges.end());
  long long int ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    int U = edges[i].second.first;
    int V = edges[i].second.second;
    long long int W = edges[i].first;
    U = find(U);
    V = find(V);
    if (U == V) continue;
    long long int sum = W * sz[U];
    sum *= sz[V];
    ans += 2 * sum;
    join(U, V);
  }
  long long int qtd = n;
  qtd *= n - 1;
  printf("%.10f\n", (ans * 1.0) / qtd);
}
