#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int p[MAX], c[MAX];
void init(int n) {
  for (int i = 1; i <= n; ++i) p[i] = i, c[i] = 1;
}
int parent(int x) { return p[x] == x ? x : p[x] = parent(p[x]); }
void join(int x, int y) {
  c[parent(x)] += c[parent(y)];
  p[parent(y)] = parent(x);
}
int cnt(int x) { return c[parent(x)]; }
long long N, E;
vector<int> adj[MAX];
pair<long long, long long> w[MAX];
int v[MAX];
int main() {
  cout << fixed << setprecision(9);
  cin >> N >> E;
  init(N + 1);
  for (int i = 0; i < N; ++i) {
    cin >> w[i].first;
    w[i].second = i + 1;
  }
  int x, y;
  double ans = 0;
  for (int i = 0; i < E; ++i) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  sort(w, w + N, greater<pair<long long, long long> >());
  for (int i = 0; i < N; ++i) {
    x = w[i].second;
    v[x] = 1;
    for (int j = 0; j < adj[x].size(); ++j) {
      y = adj[x][j];
      if (v[y] == 0) continue;
      if (parent(x) != parent(y)) {
        ans += 1.0 * w[i].first * cnt(x) * cnt(y);
        join(x, y);
      }
    }
  }
  ans /= (N * (N - 1)) / 2;
  cout << ans << "\n";
  return 0;
}
