#include <bits/stdc++.h>
using namespace std;
long long int n, m, res, arr[200000], ata[200000], size[200000];
pair<long long int, pair<long long int, long long int> > w[200000];
int atabul(int nod) {
  return nod == ata[nod] ? nod : ata[nod] = atabul(ata[nod]);
}
void birlestir(int x, int y, long long int c) {
  int a, b;
  a = atabul(x);
  b = atabul(y);
  res += size[a] * size[b] * c;
  size[a] += size[b];
  ata[b] = ata[a];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (long long int i = 1; i <= n; i++) cin >> arr[i], ata[i] = i, size[i] = 1;
  for (long long int i = 1; i <= m; i++) {
    cin >> w[i].second.first >> w[i].second.second;
    w[i].first = min(arr[w[i].second.first], arr[w[i].second.second]);
  }
  sort(w + 1, w + m + 1);
  for (long long int i = m; i >= 1; i--) {
    long long int x, y, c;
    x = w[i].second.first;
    y = w[i].second.second;
    c = w[i].first;
    if (atabul(x) != atabul(y)) birlestir(x, y, c);
  }
  cout << 2.0 * res / (n * (n - 1)) << endl;
}
